Difficulty: Extremely Easy
Almost everyday you'll fill out a webform written in html. You might not know it but when you press the "accept" button their is usually a php script being executed!
Today were going to learn how to program a simple webform where you'll enter your name and the variable will be passed to a php script in which it will be output using the "echo" function!
Step 1:
We going to create a simple webform as below...
As you can see above this will create a simple form with and input bogs and a submit button. At the top where it says ( <form action="output.php" method="post"> ) this is defining that when the submit button of the form is pressed the output.php script will be executed!
Step 2:
Now that we've created the webform we will now create the output.php file!
The above script is very simple. It gets the post "variables" from the form we created. The variable, as defined in the form is 'name'. It gets the text value the user enters and turns it into the $name variable. Note, all variables in php are started with a "$" sign!
The third line has the php script output the value of the name variable!
Step 3:
Upload these files to your webserver, run the form and it should work!
Congratulations...
Almost everyday you'll fill out a webform written in html. You might not know it but when you press the "accept" button their is usually a php script being executed!
Today were going to learn how to program a simple webform where you'll enter your name and the variable will be passed to a php script in which it will be output using the "echo" function!
Step 1:
We going to create a simple webform as below...
Code:
<form action="output.php" method="post">
Name: <input type="text" name="name"><br>
<input type="Submit">
</form>
As you can see above this will create a simple form with and input bogs and a submit button. At the top where it says ( <form action="output.php" method="post"> ) this is defining that when the submit button of the form is pressed the output.php script will be executed!
Step 2:
Now that we've created the webform we will now create the output.php file!
Code:
<?
$name=$_POST['name'];
echo "$name";
?>
The above script is very simple. It gets the post "variables" from the form we created. The variable, as defined in the form is 'name'. It gets the text value the user enters and turns it into the $name variable. Note, all variables in php are started with a "$" sign!
The third line has the php script output the value of the name variable!
Step 3:
Upload these files to your webserver, run the form and it should work!
Congratulations...


