
4:30
Learn how to handle form submissions with PHP's $GET superglobal. Check if a form was submitted using isset($_GET['name']), store the value in a variable, then use die() and echo to display a greeting instead of the form again.

Learn how to handle form submissions with PHP's $GET superglobal. Check if a form was submitted using isset($_GET['name']), store the value in a variable, then use die() and echo to display a greeting instead of the form again.
Hello and welcome to part 2 of forms. Right now we are going to be using GET to retrieve our variables. So before we show our form here, since we're sending the variables to our same file where the form is, we are going to have to check for the variables to see if the form has been submitted before. We do this by By just choosing a random variable and we retrieve it. Get works like this: you open it like any normal variable, but you do dollar sign underscore G-E-T, and it's basically like an array if you've seen the array tutorials. Open up your brackets, choose the name of The variable you're trying to access, which is in this case name. And we need to assign this to a variable. Name equals getName. Perfect. And here's a little tool or function. If isset name. Basically, this checks if name has been assigned before. If it has, then it means that our user has submitted the form, therefore assigning a name to $name. Now I don't want this form to display twice, so I'm going to use a die. And from die, we can echo out stuff like a little error message, but in this case, I'm just going to use it to say hello. Just like that. Name will equal Sean, and then it'll say hello Sean. That is all for the Git tutorial. See the post tutorial to learn how you can securitize Your forms more.