NameSilo

How to convert CSS page into PHP?

Spaceship Spaceship
Watch

BH

Established Member
Impact
2
I have to create [Rebuild an existing site] a PHP page from a CSS/HTML page. Is there any easy way for this? The layout should be similar as www.newgenresoft.com/webhosting.htm

Thanks in advance for your helps. The previous Css design should be altered int the whole website with new php pages. Do I have to start completely a new project or can embed the coding?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
embed what coding? What is it that you want to use php for?
 
0
•••
Just rename the page with .php extension.

Add PHP tags wherever you want to. It will keep your existing HTML/CSS intact as well as give you the power of PHP which you can use in between.
 
0
•••
Convert a simple HTML template to CSS freelance project is offered at getafreelancer. You will need to have Coder account before you place your bid. If interested, you can get your getafreelancer account. In case you already have an account with getafreelancer, You can check Projects Details and Apply for Convert a simple HTML template to CSS Freelance Project.

i dont think he is liking to spend money. hey maybe if you can convert it to html, then using softwares like RapidPHP, you can easily convert HTML into PHP
 
0
•••
Just rename the page with .php extension.

Add PHP tags wherever you want to. It will keep your existing HTML/CSS intact as well as give you the power of PHP which you can use in between.
as always, just do what nick says. it's a quick and simple solution. :tu:
 
0
•••
i wont recommend getafreelancer id rather ask for help around here. :)
 
0
•••
well, i dont there is any special programming, just create your php file and css attributes. It shud work.
 
0
•••
i dont think he is liking to spend money. hey maybe if you can convert it to html, then using softwares like RapidPHP, you can easily convert HTML into PHP

:) that's a good advice.
 
0
•••
If I undersstand right, you just want to put some php into a html file?

The CSS will work with whatever filetype you use as long as you link it in.

Just rename the file to .php instead of .html

then put your php code in where you like, between <?php and ?> tags.

You dont need to use any programs to do that for you :/
 
0
•••
If I undersstand right, you just want to put some php into a html file?

The CSS will work with whatever filetype you use as long as you link it in.

Just rename the file to .php instead of .html

then put your php code in where you like, between <?php and ?> tags.

You dont need to use any programs to do that for you :/

Thanks for your kind advice
 
0
•••
shockie,
renaming index.html to index.php is not just an easy solution, it is the main solution. There is no other way. You just change the extension and that's it.

Hanratty , Saket, what are you talking about? You haven't gut a clue.
 
0
•••
shockie,
renaming index.html to index.php is not just an easy solution, it is the main solution. There is no other way. You just change the extension and that's it.

Hanratty , Saket, what are you talking about? You haven't gut a clue.

Are you sure about this? will just changing the extension can help in the right way?

thanks
 
0
•••
BH, I'm a web designer. Of course I'm completely sure. Let's say you have a bunch of web pages like this: index.html, about.html, contact.html
Just rename the files to this: index.php, about.php, contact.php

If you are using dreamweaver or any other web editor, do the renaming inside the editor. This will update any links automatically. For instance if your logo is linking to the homepage, it won't work anymore if you do the renaming manually unless you go inside the code and update the link as well. If you want to do the renaming manually and can't see the file extensions then you need to change your computers settings to display file extensions.

If you rename index.html to index.php what is happing is that you are telling the browser on clients machine that this is a php file and any php code inside the file should be executed. If there are no php codes inside the page, then the browser will look inside and do nothing except loading the page normally as it would do if it was index.html.

I usually start building my website in html file format. Then after I have the header and footer sections ready, I move them to separate mini pages and include those mini pages inside each main page. Those mini pages are called PHP includes.

This is how it works:

1. Inside my main directory I create a folder called includes.
2. Inside that folder I create a file called menu.html but this file is comnpletely blank. It does not have any head, body sections etc. You can open notepad and save the blank file as menu.html inside the includes folder.
3. Then I go to my index.html page and cut all the section that is related to the menu and paste it to the menu.html file I just created.
4. Now, there is no menu in the index.html file because I moved it to an external file. Therefore I need to include the menu.html file inside my index file. To do this I put this code inside the index file where the menu code used to be:
Code:
<?php include("includes/menu.html"); ?>
5. As you see the above says, include the menu.html file inside this file. The problem is, this is a PHP code but I have an index.html file. What should I do now? Of course I just rename my index.html file to index.php file and now it works. (This will work on the website after you have uploaded the new files to your host. It wont work on your local machine, unless you have installed a local server on your computer for testing purposes, which I did).
6. Now you can go ahead and do the same to all your files that have the menu. What is the advantage? The advantage is that, when you need to change the menu you only change and upload the menu.html file and all your pages will be updated. You can of course use Dreamweaver templates instead PHP includes but then you have to upload all your pages.
7. I usually create PHP includes for the header, menu footer and head sections. The head section is an area inside the head tags that includes meta tags and site name. Basically, whatever is common in all pages, gets to be moved to PHP includes. If there are any pages on the site that don't have any PHP code inside them you just rename them to PHP as well, because otherwise your site will look amateurish.
8. If your links don't work after you have moved the menu or footer to an included file, then change your links to absolute links instead relative links. If you don't know this post here and I will explain.


Two small notes:
1. Nick, who posted earlier in this thread was spot on.
2. The title for this thread should be "How to convert an HTML page to PHP?".


Erdinc
 
Last edited:
0
•••
Or another solution (which may be better if you have a LOT of .html files and don't want to spend time renaming them all / remaking all your hyperlinks) is to just add .html to PHP's parsing list.

Make an .htaccess file in the root of your website and add:

Code:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Now your .html files should also have anything within <?php ?> tags parsed.
 
0
•••
My first question... does your server support PHP? :)
 
0
•••
My first question... does your server support PHP? :)

easy way to check is to upload a file called info.php (or anything else as long as it ends in .php) and put the following into the file:-

PHP:
<?PHP
phpinfo();
?>

Then navigate to the page. You should see a whole load of information. If you only see the content of the file however then php is not installed.

Just a not. PHP and HTML are 2 completely different things. The advise you have here is actually how to contain html in a PHP file. HTML is simply a language that tells the browser how to display a webpage whereas PHP is a server side language that is processed prior to the server sending the result to the client (the result generally being HTML).
 
0
•••
Peter,

Thank you for explaining that to him, I wasn't even thinking of that when I replied to him. :)
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back