HTML, PHP, SQL.

fallenapples

In Runtime
Messages
386
Location
Toronto, Ontario
So far throughout my course I have been able to create a sample website with all pages being .php except for the style sheet of course which is .css. Each page of the course web site is saved as .php files, the header page 1, 2, 3, the footer etc.

I have a site of my own I created a while back with Dream Weaver. It is just 2 pages both html and css. Do I have to change both files to a .php extension to get it to work with mySQL on XAMPP or can I embed the php code within the content? I want to create a registration menu and link it to a database. Could I just create an html registration filed and create a my_sql connect.php page and put it in my site folder?
 
You have to change the extension to .PHP so that it can actually run the PHP code on the server.

Even if you just have an HTML form, you'll still need to the submit behavior to redirect to an intermediate PHP page that does the Database data processing.

For example, on one small project I did for a business in creating a website, they wanted an email form. Now since HTML can't send email (needs a server to fire off the email), and I didn't want to change the page itself to a PHP page... So what I did, is have the form do it's submit behavior. The form redirects to an intermediate PHP page. The PHP page then gets the POST data from the previous HTML form, then sends the email from the server executing the PHP code, and then the PHP form redirects back to the main HTML page. The intermediate PHP page can only be seen for a split second if the server takes some time to send the email.
 
Thank you. One thing that confuses me a little is that I was instructed to create a small nav column, a footer. header and such all in separate .php files. Then I had to create a template file that used the php include function to include each file [nav column, footer, header] It just seemed like more work; opposed to just creating them in one html/css file. Anyway, so I do not have to create a separate file for the registration form right? Just along as the web pages are .php extensions.
 
Thank you. One thing that confuses me a little is that I was instructed to create a small nav column, a footer. header and such all in separate .php files. Then I had to create a template file that used the php include function to include each file [nav column, footer, header] It just seemed like more work; opposed to just creating them in one html/css file.
HTML itself doens't support templating - there is no way to "include" other/external files.

It may seem like more work up front, but in the real world for projects...separating stuff out makes things MUCH easier. Because then you can update just those components, or even reuse them in other projects and then just change the CSS for them, or other smaller pieces.

Anyway, so I do not have to create a separate file for the registration form right? Just along as the web pages are .php extensions.

Correct.
 
Back
Top Bottom