title: I am attempting to make a login using phpmyadmin, but, when I click submit, it inserts blank entries into the database
body: <p>My class is attempting to make our own game.. But, we can't get the submit page to send to the database in PhpMyAdmin. When you click submit, it sends blank entries to the database, like if you hadn't filled in any of the blanks. Can someone help with this problem. Thanks!!</p>
  
  <p>My index.php page.</p>
  
  <pre><code>&lt;html&gt;
  
    &lt;head&gt;
  
      &lt;meta charset="UTF-8"&gt;
  
      &lt;title&gt; Register New Account &lt;/title&gt;
  
      &lt;link rel="stylesheet" type="text/css" href="td.css"&gt;
  
    &lt;/head&gt;
  
  
  
    &lt;body&gt;
  
    &lt;?php
   /* $count=$count+1;
    echo " count " . $count; */
  
  
      if($_POST['submit_id'] == 1)
        {
  
       /* echo "testing"; */
  
      if($_POST['Username'] == NULL)
        { 
          $message = 'Please enter your Username.';
        }
  
      if($_POST['Email'] == NULL)
        { 
          $message = 'Please enter your Email.';
        }
  
      if($_POST['Confirm'] == NULL)
        { 
          $message = 'Please re-enter your Email.';
        }
  
      if($_POST['Password'] == NULL)
        { 
          $message = 'Please enter your Password.';
        }
  
      if($_POST['Email'] != $_POST['Confirm'])
        { 
          $message = 'Your emails did not match, Please enter your emails again.';
        }
  
    }
      if( $message == NULL )
        {
            // if there is no error, test to see if there is already an account by the player_name
  
            $MySQLlink = new mysqli("localhost", "root", "******", "Tower_Defense");
  
            // check connection - take out later
  
            if ( !$MySQLlink )
              {
                printf( "Could not connect to MySQL server : %s", mysqli_connect_error() );
                exit();
              }
            else
              {
                printf( "Connected to the MySQL server" );
                echo "&lt;br&gt;";
             } 
  
            $result = mysqli_query( $MySQLlink, "SELECT * FROM Users WHERE  ( email = 'email' ) " );
  
            if($row = mysqli_fetch_array($result))
                {
                  $message = "There is an account with that email address already. Please choose another email account";
                }
  
            mysqli_free_result($result); 
  
            $result = mysqli_query( $MySQLlink, "SELECT * FROM Users WHERE  ( Username = '$Username' ) " );
  
            if( $row = mysqli_fetch_array($result) &amp;&amp; $message == NULL )
                {
                  $message = "There is an account by that player name already. Please choose another Login name";
                  mysqli_free_result($result);
                }
  
            else
                {
                //echo "next date &lt;br&gt;";
                    // create account 
                    $Username        = ($_POST['Username']);
                    $Password        = ($_POST['Password']);
                    $Email           = ($_POST['Email']);
                    $email           = ($_POST['email']);
               //echo "Next one&lt;br&gt;";
  
  
                    $TableList = "  `Username`, `Password`, `Email`, `Confirm`   ";
  
                    $Values    = "  '$Username', '$Password', '$Email', '$Confirm'   ";
  
  
      if($message != NULL)
        { 
  
          echo "$message";
        } 
  
      ?&gt;
  
    &lt;div id="container" &gt;
  
          &lt;div id="header"&gt;
  
              &lt;h1 id="h1"&gt;Besco's Biscuits&lt;/h1&gt;
  
              &lt;a href= "http://192.168.131.**/towerdefence/about/index.html" id="a1"&gt;About&lt;/a&gt;
  
              &lt;a href="http://192.168.131.**/towerdefence/instruction/index.html" id="a2"&gt;Instructions&lt;/a&gt;
  
              &lt;a href="http://192.168.131.**/towerdefence/create/index.html" id="a3"&gt; The Creation Of The Game&lt;/a&gt;
  
              &lt;a href="http://192.168.131.**/towerdefence/cu/index.html" id="a4"&gt;Contact Us&lt;/a&gt;
  
          &lt;/div&gt;
  
  
  
  
    &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
      &lt;table align = "center"&gt;
        &lt;tr&gt;
      &lt;td&gt;
  
        Welcome to &lt;b&gt; Besco's Biscuits &lt;/b&gt;. Please fill out the following &lt;br /&gt;
        areas and we will begin your adventure soon. :)
  
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
  
  
      &lt;table align = "center"&gt;
        &lt;tr&gt;
      &lt;td&gt; 
         &lt;form action = "&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;" method="post"&gt; &lt;br /&gt;
          Username: &lt;input type="text" name="Username" id= "Username"&gt; &lt;br /&gt;
          Email: &lt;input type = "text" name = "Email" id= "Email"&gt; &lt;br /&gt;
          Confirm: &lt;input type = "text" name = "Confirm" id= "Confirm"&gt; &lt;br /&gt;
          Password: &lt;input type = "password" name = "Password" id = "Password"&gt; &lt;br /&gt;
          &lt;input type = "submit" value = "Register" id="submit_id" value = "1"&gt; &amp;nbsp; &amp;nbsp; 
          &lt;input type = "reset" name="Reset" value="Check if Available!" class = "account"&gt;
  
  
        &lt;/form&gt;
      &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
  
  
  
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>My insert.php page</p>
  
  <pre><code>&lt;html&gt;
  
    &lt;body&gt;
  
  
      &lt;?php
      $Username = $_POST['name'];
        $con=mysqli_connect("localhost", "root", "******", "Tower_Defense");
  
        //Check Connection
  
        if (mysqli_connect_errno())
      {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
  
        $sql="INSERT INTO Users (Username, Email, Confirm, Password)
        VALUES
        ('$_POST[Username]','$_POST[Email]',' $_POST[Confirm]',' $_POST[Password]')";
  
        if (!mysqli_query($con,$sql))
      {
        die ('Error: ' . mysqli_error($con));
      }
        else 
      {
        echo "1 record added"; 
        echo $_POST[Username];
        //echo "Where is Username?";
        echo $_POST[Email];
        //echo "Where is Email?";
        echo $_POST[Confirm];
        //echo "Where is Confirm";
        echo $_POST[Password];
        //echo "Where is Password";
      }
  
  
  
  
        mysqli_close($con);
        ?&gt;
  
    &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>UPDATE:</p>
  
  <p>I added in the changes that someone had suggested in moving the checks to insert.php and now the email and confirm email check does not work. Can anyone help? </p>
  
  <p>index.php</p>
  
  <pre><code>&lt;html&gt;
  
    &lt;body&gt;
  
  
  
    &lt;div id="container" &gt;
  
          &lt;div id="header"&gt;
  
              &lt;h1 id="h1"&gt;Besco's Biscuits&lt;/h1&gt;
  
              &lt;a href= "http://192.168.131.34/towerdefence/about/index.html" id="a1"&gt;About&lt;/a&gt;
  
              &lt;a href="http://192.168.131.34/towerdefence/instruction/index.html" id="a2"&gt;Instructions&lt;/a&gt;
  
              &lt;a href="http://192.168.131.34/towerdefence/create/index.html" id="a3"&gt; The Creation Of The Game&lt;/a&gt;
  
              &lt;a href="http://192.168.131.34/towerdefence/cu/index.html" id="a4"&gt;Contact Us&lt;/a&gt;
  
          &lt;/div&gt;
  
  
  
  
    &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
      &lt;table align = "center"&gt;
        &lt;tr&gt;
      &lt;td&gt;
  
        Welcome to &lt;b&gt; Besco's Biscuits &lt;/b&gt;. Please fill out the following &lt;br /&gt;
        areas and we will begin your adventure soon. :)
  
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
  
  
      &lt;table align = "center"&gt;
        &lt;tr&gt;
      &lt;td&gt; 
         &lt;form action = "insert.php" method = "post"&gt; &lt;br /&gt;
          Username: &lt;input type="text" name="Username" id= "Username" required = "1"&gt; &lt;br /&gt;
          Email: &lt;input type = "text" name = "Email" id= "Email" required = "1"&gt; &lt;br /&gt;
          Confirm: &lt;input type = "text" name = "Confirm" id= "Confirm" required = "1"&gt; &lt;br /&gt;
          Password: &lt;input type = "password" name = "Password" id = "Password" required = "1"&gt; &lt;br /&gt;
          &lt;input type = "submit" value = "Register" id="submit_id" value = "1"&gt; &amp;nbsp; &amp;nbsp; 
          &lt;input type = "reset" name="Reset" value="Reset Page" class = "account"&gt;
  
  
        &lt;/form&gt;
      &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
  
  
  
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>insert.php</p>
  
  <pre><code>&lt;html&gt;
  
    &lt;body&gt;
  
  
      &lt;?php
  
     if($_POST['submit_id'] == 1)
        {
  
       echo "testing"; 
  
      if($_POST['Email'] != $_POST['Confirm'])
        { 
          $message = 'Your emails did not match, Please enter your emails again.';
        }
  
        }
      if( $message == NULL )
        {
            // if there is no error, test to see if there is already an account by the player_name
  
            $MySQLlink = new mysqli("localhost", "root", "abc123", "tower_defense");
  
            // check connection - take out later
  
            if ( !$MySQLlink )
              {
                printf( "Could not connect to MySQL server : %s", mysqli_connect_error() );
                exit();
              }
            else
              {
                printf( "Connected to the MySQL server" );
                echo "&lt;br&gt;";
             } 
  
            $result = mysqli_query( $MySQLlink, "SELECT * FROM Users WHERE  ( email = 'email' ) " );
  
            if($row = mysqli_fetch_array($result))
                {
                  $message = "There is an account with that email address already. Please choose another email account";
                }
  
            mysqli_free_result($result); 
  
            $result = mysqli_query( $MySQLlink, "SELECT * FROM Users WHERE  ( Username = '$Username' ) " );
  
            if( $row = mysqli_fetch_array($result) &amp;&amp; $message == NULL )
                {
                  $message = "There is an account by that player name already. Please choose another Login name";
                  mysqli_free_result($result);
                }
  
            else
                {
                //echo "next date &lt;br&gt;";
                    // create account 
                    $Username        = ($_POST['Username']);
                    $Password        = ($_POST['Password']);
                    $Email           = ($_POST['Email']);
                    $email           = ($_POST['email']);
               //echo "Next one&lt;br&gt;";
  
                     }
      }
  
  
      if($message != NULL)
        { 
  
          echo "$message";
        } 
  
  
  
        $con=mysqli_connect("localhost", "root", "abc123", "tower_defense");
  
        //Check Connection
  
        if (mysqli_connect_errno())
      {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
  
        $sql="INSERT INTO Users (Username, Email, Confirm, Password)
        VALUES
        ('$_POST[Username]','$_POST[Email]',' $_POST[Confirm]',' $_POST[Password]')";
  
        if (!mysqli_query($con,$sql))
      {
        die ('Error: ' . mysqli_error($con));
      }
        else 
      {
        echo "1 record added"; 
        echo $_POST[Username];
        //echo "Where is Username?";
        echo $_POST[Email];
        //echo "Where is Email?";
        echo $_POST[Confirm];
        //echo "Where is Confirm";
        echo $_POST[Password];
        //echo "Where is Password";
      }
  
  
  
  
        mysqli_close($con);
        ?&gt;
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>