phparrayspostsubmissionsuperglobals

Why check if isset($_POST['Submit']) before accessing other $_POST elements?


What is this code doing? If Isset, and what are the variables doing, whats the $_POST doing? Can someone explain please?

if (isset($_POST['Submit'])) {
    $title=$_POST['title'];
    $forename = $_POST['forename']; 
    $surname=$_POST ['surname'];
    $dateofbirth=$_POST ['dateofbirth'];
    $gender=$_POST ['gender'];
    $email=$_POST['email']; 
    $phone=$_POST['phone'];
    $passcode1=$_POST ['passcode1'];
    $passcode2=$_POST ['passcode2'];

Solution

  • If a form is being submitted, then it assigns variables.