This is an intro into php forms for beginners.What's about this 2 functions? You can handle forms submits(you can't using just html)First of all let's take an example:echo $_GET['name'];
?>
The example above is a get request, to use it type into browser filename.php?name=thecodertipsIt will echo out 'thecodertips' into the browser.What's different between get and post? Get can be shown into url and post not. Get method should not be used when submitting passwords.Post example:echo $_POST['name'];
?>
How to go with post now? There must be a form to submit the request:
echo $_POST['hi'];
?>
The php code handles the input of the text box with the name 'hi', note! "Box name(name=) should be always same with the post/get name([''])action="" tells the browse to which file it should submit the datamethod="" can be get or postSo far so good, but how to check if user submitted anything or not?We can use isset, empty.// usage: empty, isset, !empty, !isset
if(isset($_GET['name'])){
echo 'your name is '.$_GET['name'];
}
else{
echo 'enter your name';
}
?>
Hope you liked this simple lesson on form handling.
We appreciate you for reading our post, but we think it will be better you like our facebook fanpage and also follow us on twitter below.
Title :
Working with forms, $_GET - $_POST form submit
Description : This is an intro into php forms for beginners. What's about this 2 functions? You can handle forms submits (you can't using just ...
Rating :
5