Taste of Web development using PHP
Well at this stage, we know how to setup PHP, MySql and Apache. We have installed either XAMP or WAMP (ready made package of PHP, MySql and Apache). Moreover we run a simple PHP script hello_world.php. Which means now we are able to create a project, write php code and run it in browser.
Lets move forward with a simple page with some HTML controls. Lets define our requirement first.
It’s a member information page with the following fields: first name, last name, email, contact no, present address and sex. When we enter data and submit this page it will goes to another page and shows the information. That’s all for today.
Lets start. Our first task is to create a simple page member_info.php. Now lets add the fields first name, last name, email, contact no, present address and sex. Before write a single line of code we have to think first, which HTML fields we will use. For first name, last name, email address it’s fair to choice text box. Moreover, for present address wise to select text area as though address need multiple line of input. Lastly, for sex it’s clever decision to choose radio button with predefined values Male and Female. So here is our page member_information.php.
Untitled Document
| Welcome to Member Information Page | |
| First name | |
| Last Name | |
| Address | |
| Sex |
Male
Female |
Now when you browse this page (like: http://localhost/project_name/member_information.php ) you will get all fields of your page. When you enter some informations and press submit the page goes to http://localhost/project_name/success.php. Lets clarify how is it works. if you observe this page closely you found
//some html controls.. text box, radio button and submit button
A submit button is fully responsible to submit the page to server along with all inputed informations. And form action=”success.php” define where these informations will be submitted. As a result it submits to success.php. Hey!!! It shows you No page Found 404 Error Right? Don’t worry. You are correct. Just make sure your URL (at address bar) end with success.php.
Well at second step. lets build success.php. This is a simple page where we show all data inputed at member_information.php. Here is the code of success.php
Untitled Document
| Welcome to Member Information Page | |
| First name | |
| Last Name | |
| Address | |
| Sex | |
So you get your inputed data. right? Right now you url in address bar is http://localhost/project_name/success.php Lets analyze success.php. Actually we use here $_POST['field_name'] to display any field_name value. By example, we have
which means address is a HTML field what is submitted to success.php through a POST method. Lets remind our mind we have
in member_information.php page.
that’s all for today. Try yourself to understand how this page is working. test by add some fields like phone number in member_information.php page and display it at success.php.
Best of luck



