DyingLoveGrape.

(home) (about) (rss)

Part 4, Section 3:
Web Development and Security.





You down with PHP?

Think about our LAMP framework as a bakery. Customers come in and ask the baker's assistant behind the counter for a particular kind of customized cake. The baker's assistant then takes those orders and hands them to the baker. The baker then goes to the stockroom and gets the ingredients, makes the cake, and gives it to the customer. In the same respect, the user goes to a website and puts in data (which are specific instructions, usernames, passwords, etc.) which is taken via PHP to the server, Apache. Apache then goes to the stockroom, which is SQL, and looks up and takes whatever data it need, and finally returns the request to the user.

As a real example, if a user goes to a webpage and puts in their username and password, PHP will take those values for username and password and hand them off to Apache, which will look them up in an SQL database and check the username (to see if they're actually a signed-up user) and check the password (to see if it's correct) and once that's done Apache will send the user to their logged-in homepage.

So, what's the difference between HTML and PHP? In the case of the bakery, HTML is more of how the bakery looks — it is the structure of the bakery: the counter, the display case, the ordering forms, the doors, and so forth. PHP is the baker's assistant: it isn't part of the architecture of the bakery, but it does the leg-work to bring things to Apache. It's easier to see the difference after you've coded for a bit, but if you're curious for a more concise answer, look here.

Important Note: PHP can be tricky. Make sure every line ends in a semicolon (like MySQL!), and make sure you spell everything right. Because we're doing this in gedit, there is no debugging which means if you run your PHP and it's not correct, you'll just return a blank page. Hence, if you get a blank page after doing your PHP and the page should not be blank, check your code and make sure there are no typos.

Other Important Note: Practice all of the following stuff in the index.html file that you made for the LAMP section above; but you will need to rename the file index.php in order for PHP to work. In general, if you have PHP in an HTML file, you'll want the file extension to be .php.



⇐ Back to 4.2HomeOnwards to 4.4 ⇒