New to PHP - Just Some Pointers.

Associate
Joined
27 Jan 2005
Posts
830
Okay, I have a site with 4 pages:
-Home
-About
-Services
-Contact

The contact page will need a contact form creating - I will want it to be styed to fill the theme of the site. It will require options as well so the user can select what department the email is to be sent too.

I don't require, at this stage, a database implemented into this whole thing as i'm not interested in collection various data. I just want a email form in my site that can forward email when the user presses 'submit'.

At the moment everything is in the Photoshop stage and have been reading a little about PHP, but I do have a couple of questions.

I understand server side technology will be rewquired to make the contact form work. I will, of course, be using PHP.

1) Only the Contact form will have anything to do with PHP. However, should all the pages end in .php. Example:
-Home.php
-About.php
-Services.php
-Contact.php

2) So it's possible to create all the pages in .xhtml then just rename them all to .php?

3) The contact page will obviously need the php attention. Is it basically a case of coding that page normally with the correct html and CSS and making sure the extension of that page ends in .php?

4) The php itself - can it be placed in that page with all the rest of the html or does it go into a seperate .php file?
 
only pages that have server side scripting on will need to end in php (not actually true as html files can run php but i wont get into that)

you can create a page and name it whatever you want and the rename it at any point. just got to remember to rename and links to the new name.

the contact page doesn't need to be a .php file as the form can be submitted to any page such as contact.html can submit to process.php which when complete redirects back to contact.html

the php can go wherever you want as long as the page has a .php extension and is wrapped in <?php [code here] ?>
 
1) Only the Contact form will have anything to do with PHP. However, should all the pages end in .php. Example:
-Home.php
-About.php
-Services.php
-Contact.php

You can mix as many different names as you like. Alternatively you could use something called mod_rewrite [here] to make your URLS appear like:
/home
/about
/services
/contact

Without extensions. Or you could just create a folder for 'home', 'about', 'services' etc and put an index.php file inside there with whatever content you require, this will have the same effect.

2) So it's possible to create all the pages in .xhtml then just rename them all to .php?

.xhtml isn't a valid filename I don't think, but either way yes it's possible. A .php page can contain any HTML you like much like a .htm or .html file.

3) The contact page will obviously need the php attention. Is it basically a case of coding that page normally with the correct html and CSS and making sure the extension of that page ends in .php?

You only need to make sure that the page receiving the form data (when you create a form you tell it where to send the submitted data to) is a php page. This could be itsself, in which case yes the page would need to be a php file.

4) The php itself - can it be placed in that page with all the rest of the html or does it go into a seperate .php file?

It can be placed in the page itself, but depending on how complex you make the site it's sometimes best to put it in separate files especially if you want to re-use certain code over all your pages.



edit: beat :(.
 
You can mix as many different names as you like. Alternatively you could use something called mod_rewrite [here] to make your URLS appear like:
/home
/about
/services
/contact

Without extensions. Or you could just create a folder for 'home', 'about', 'services' etc and put an index.php file inside there with whatever content you require, this will have the same effect.



.xhtml isn't a valid filename I don't think, but either way yes it's possible. A .php page can contain any HTML you like much like a .htm or .html file.



You only need to make sure that the page receiving the form data (when you create a form you tell it where to send the submitted data to) is a php page. This could be itsself, in which case yes the page would need to be a php file.



It can be placed in the page itself, but depending on how complex you make the site it's sometimes best to put it in separate files especially if you want to re-use certain code over all your pages.



edit: beat :(.

Thanks for that. I was wondering why sites didn't show what file it was in the address.

Thanks for help.
 
Thanks for that. I was wondering why sites didn't show what file it was in the address.

Thanks for help.

Google have told the masses to avoid using mod_rewrite to make URLs more user friendly. I don't know why, they just have.

Either way you can create the navigation via a folder structure, ie folders called "about", "services" etc with an index.php in each.
 
Back
Top Bottom