Copy and paste php in an existing html page

12 posts by 3 authors in: Forums > CMS Builder
Last Post: April 22, 2010   (RSS)

By trickster - April 21, 2010

Hi,

I don't profess to be a code writer. I have built several websites in html and they have worked fine. I can even fake it for some of the basic coding by editing, cutting and pasting.

I am somewhat disappointed by the level of difficulty which your product seems to require. I have been struggling with adding your code generator code to my clients existing site. Your advertising sounds easy, but I am here to tell you it isn't easy. I don't want to have to ask for a refund, but I will have to soon if I can't get this to work.

I noticed a forum posting that stated problems with php in an existing html site. Is this true? Is that why I am having soo much trouble. Your literature doesn't state that you have to start using your software with a new php only site. I would like to know if I need to be a programmer to use your software or is it a software problem.

Thanks for your prompt reply

Re: [trickster] Copy and paste php in an existing html page

By Dave - April 21, 2010

Hi trickster, welcome to the CMSB forum! :)

What is the specific problem you are having or error you are getting?

For an existing site you do need to either change the extensions to .php or tell your webserver to treat .html files as .php files:
http://www.interactivetools.com/docs/cmsbuilder/file_extensions.html

You don't have to be a programmer (most people in the forum aren't), and it is very easy compared to any other method of building a custom CMS, but you still may need to give yourself some time to get familiar with it.

Start with small steps, I'd recommend getting a test script like this working on your server first:
<?php
# save this file as hello.php
print "Hello World from PHP";
?>


Then saving the generated viewer code with the recommended .php filenames and getting that to display properly, then work on integrating that with your existing html code but with a .php extension (so your existing pages aren't modified until you are ready).

Hope that helps. Keep us up to date with your progress!
Dave Edis - Senior Developer
interactivetools.com

Re: [gkornbluth] Copy and paste php in an existing html page

By trickster - April 21, 2010

Hi,

Thanks for your reply.

Soo, I am able to see the php code generated as a page in a browser. Then when i try to copy and paste it into my existing page I run into problems. I guess I don't quite understand how it all works. If i copy and paste into my existing page, then edit the code using frontpage, am I destroying the link between the saved file (example: newslist.php). It is my understanding that whatever i do for edits should probably be done in the original file that I create in csm builder. When i generate that code, i am stuck with it, unless i go back into csm builder and change and regenerate it... is this true.

I am trying to make my clients website updateable by them. I need to know that whatever i create and copy paste into the existing website... that it will reflect any changes they might make as an editor.

This is a hell of alot harder than it you guys make it out to be.

Thanks for your help

Re: [Dave] Copy and paste php in an existing html page

By trickster - April 21, 2010

Hi,

I'm not sure what you wanted me to do with this code:

<?php
# save this file as hello.php
print "Hello World from PHP";
?>


I copied it into a simple text program, saved it as a php extension and uploaded it to my root file directory.... i got nothing.

I have had success with the code generator and pasting code into a simple text doc with a php extension. The above code you wrote should work in theory, but when i save it to the directory on my server and type mydomainsurl/hello.php... I get nothing.

A question another user had raised, questioned the changing of the files on my server from html to php. He stated that this would render all the search engine links that exist presently, null and void, due to the change in file name. This is true is it not? Is there any way around this?

Am I going to have lots of problems embedding the php code into my existing webpages if i don't change them to php extensions?

Thanks

Re: [trickster] Copy and paste php in an existing html page

By trickster - April 21, 2010

Hi again,

I've been racking my brain trying to get this stuff to work on my clients website. This is not easy at all.

Firstly, when i paste the code into the webpage in my web design application, I don't see it properly... only when i upload the newly saved file to my server, does it show up properly. This seems very weird to me. Is it a restriction of Frontpage. If yes, then what web design software do you suggest i use?

When I view the index.php page on my server it has these words in the table where i want my new article to show up "Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/elsareim/emmanuelshepherds.com/index.php:7) in /hsphere/local/home/elsareim/emmanuelshepherds.com/index.php on line 82"

Is there a way that i can view changes that i am making to my existing website without changing the permanent files? One limitation seems to be that I can't see the pages properly unless i am viewing them from the server. This is awkward.

If this is all over my head, then just say so. It has been suggested that I buy your cms cookbook, but if that is the expectation, then maybe you should sell it as part of the package.

Very frustrated

Re: [trickster] Copy and paste php in an existing html page

By Dave - April 21, 2010

Hi Trickster,

>If this is all over my head, then just say so.

With all respect, I would say that right now it probably is, so if you choose to continue you're going to take this on like any other new technology that you may have learned such as CSS, photoshop, etc and give yourself a lot of time and patience.

If you are in a rush and need a solution ASAP this probably won't work for you. if you want a completely automated solution it also won't work for you. But if you are able to learn it you'll be amazed at the things you can do with the software.

A couple of tips:

- You're going to need to figure out how to get your editor to allow you to copy and paste PHP code and have it work when you upload it. Go through the settings or search online for tips. Almost all web editors made in the last decade support PHP tags, but some need some settings adjusted so they don't automatically wrap lines, etc.

- The next step is to get that hello.php script working. Being able to upload a test php script and getting it to run on your site is a pre-requisite for being able to use the software.

- Next, you'll need to be able to hand code HTML to use this tool. That's also a requirement so make sure you can do that.

And some answers:

Re: changing page extensions - Yes, you'll need to either name the pages PHP or use the tip I previously gave you to have your web server parse .html files as .php. And yes, some of the filenames will change. There's no easy way around this (there's some complex ways), if you're moving from a hand-coded solution to a CMS (any CMS) the urls are going to look at least a little different. The default url format we use is optimized for SEO, though, with keywords in the URL so you could end up with better rankings.

The "Cannot modify header information" error means you put something before your first PHP tag. make sure <?php is the very first thing in the page or attach the index.php file to this thread with "Upload Attachment" so we can take a look and help.

For now you will need to upload the files your website to see them. And yes this can be more time consuming. You usually make this time up during content-entry and when creating multiple pages (since new "pages" are created by the CMS.

>It has been suggested that I buy your cms cookbook

I know some users really love the cookbook, but it's not by us and there's no expectation that you buy it.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Copy and paste php in an existing html page

By trickster - April 22, 2010

Hi,

can you look at this and tell me why i am getting the error. I have tried placing the php code in multiple places and always seem to get an error.

"Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/elsareim/emmanuelshepherds.com/index.php:27) in /hsphere/local/home/elsareim/emmanuelshepherds.com/index.php on line 102"

Thanks

Re: [trickster] Copy and paste php in an existing html page

By trickster - April 22, 2010

sorry, forgot the file.
here it is, thanks.
Attachments:

index_013.php 15K

Re: [trickster] Copy and paste php in an existing html page

By Dave - April 22, 2010

Hi trickster,

Try removing this content from the middle of your page (starting on line 102):

&nbsp;<?php header('Content-type: text/html; charset=utf-8'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>


And also remove this around line 28:
</body>
</html>


Your html document already has a header and footer so you don't need to copy and paste those parts again.

Let me know how it goes.
Dave Edis - Senior Developer
interactivetools.com