Your First Site : Part 1
Hello There Sailor ... How's your smile doing?
Please note that this tutorial is part of the Build Your Own Site series of tutorials. Feel free to restart the series.
"Alright, alright, alright ..." - Matthew McConaughey
"Alright, Okay ... " - Denzel Washington
"first_site.html"
or "first_site.php
. Save the file and load it in your browser as we've done countless times before in this series of tutorials.
http://localhost/first_site.html"
should work. After loading the page, please notice that as expected, the page is empty :). Got a keen eye there Thabo.
We'll be building the page from scratch, adding every component as we go. First; the bare back html, please copy and paste it sir/madam/miss/queen:
<!DOCTYPE HTML>
<html>
<head>
<title>The First Site | Yeaaahhh Boooiiiiiyy!!</title>
</head>
<body>
Some great Content to come here ... as in be here not the uuhhmm... k neeexxxttt!!
</body>
</html>
Next we'll be adding the form to the page, essentially a contact form for your site :)
<form action="/action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
Yep that's as simple a form as we're gonna use for this tutorial Azizi. Note that it only has two inputs and a submit button. The two inputs are both text input fields, and have the field names "fname" and "lname" accordingly. Please study the code and see where we place this wonderful form in our html.
<!DOCTYPE HTML>
<html>
<head>
<title>The First Site | Yeaaahhh Boooiiiiiyy!!</title>
</head>
<body>
<form action="/action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
As usual, try your best to replicate the code above, reload the page and voila!
"Alright, Okay ... " - Denzel Washington
"/action_page.php"
. This means that once the form is submitted, meaning when the user clicks the submit button; the form data will be sent to the page "http://localhost/action_page.php"
.
The server will automatically load that page for us in the browser on form submission, and the code on that page can do whatever it wants to do with that data.
Note that the method attribute of this form is "get". GET is a method to make http requests, these are ways in which the client(browser) can pass data to/communicate with the server.
HTTP is the protocol we'll be using on Apache, comes standard. So to talk to any part/file on our server we just make an http request to it and the server will make sure that file/destination gets our message as intended. Pretty cool right?!! :)
"Note that the method attribute of this form is "get". GET is a mthod to make http requests, these are ways in which the client(browser) can communicate with the server."
The Village Geek
Alright that's enough info for one tutorial, we'll continue with this in the second part of the lesson. Go get some nuts and raisins, start a small wood fire and warm your hands will ya. We'll talk in a few :)
Cape Town, South Africa