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: [trickster] Copy and paste php in an existing html page

Hi Trickster,

Creating your first CMS pages can seem confusing in the beginning, but you'll get the hang of it soon. Once you do, you'll be amazed at the ease and flexibility CMSB offers.

You will probably want to change the extension of your pages that use PHP to .php instead of .htm or .html. This tells your server that you want the page treated as a PHP page and to pull your content information from your database. (There are ways to instruct your server to do the same with .htm and .html, but for now it's easier to change the extension.

You can run any combination of html and php pages on your site, but pretty soon I'll bet you'll be switching them all.

One major difference between HTML hard coding and CMS, is that with CMS the information displayed on the page is pulled from fields in either one, or a number of database tables (sections) that you create.

Those database tables can each contain of either one record (a single record database table (for an about us section for example), or a series of records in a multi-record table (a list of videos for example).

Let's get started creating your first page

In, in your admin area under section editors, create a simple single record editor and call it Index.

Then go to the menu of existing sections (left side of the admin page) and click on the new "Index" section that you just created.

Add some information in the fields provided, and save the record.

Now go to the code generator in the admin section and choose the Index section, and the Detail page radio button.

Paste the code generated into a blank web page, name it indextest.php and upload it to your server.

Notice where the various pieces of information appear on the viewer page and compare it to the code of the page.

You can add any fields you like to the editor, re-generate the code, and place the code snippets anywhere on your page that you'd like.

Once you get the hang of this, try inserting the code at the top of the page into your real pages, and then inserting the appropriate code snippets where you want the fields (pieces of information) to appear on your page.

It may take a bit of getting used to, but once you understand the concepts behind CMS, there's virtually nothing that can not be done with CMSB.

Hope that gets you started,

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

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: [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