title: Undefined Index PHP issue.Please help
body: <p>I have the following error:</p>
  
  <p>Notice: Undefined index: submit in C:\wamp\www\registration\register.php on line 6</p>
  
  <p>Can't seem to work out whats wrong??? Here's the code::</p>
  
  <pre><code>    &lt;?php
      //Create registration form (register.php)
      include "../includes/db_connect.php";
  
      if(!$_POST['submit']) ///Line 6
      {
      ?&gt;
      &lt;html&gt;
      &lt;head&gt;&lt;link rel="stylesheet" href="style.css"&gt;&lt;/head&gt;
  
      &lt;div class="divider"&gt;
      &lt;strong&gt;Register&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;
      &lt;form method="post" action="register.php"&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="first"&gt;First Name&lt;/label&gt;
      &lt;input id="first" type="text" name="first"&gt;
      &lt;/div&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="last"&gt;Last Name&lt;/label&gt;
      &lt;input id="last" type="text" name="last"&gt;
      &lt;/div&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="username"&gt;Desired Username&lt;/label&gt;
      &lt;input id="username" type="text" name="username"&gt;
      &lt;/div&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="password"&gt;Password&lt;/label&gt;
      &lt;input id="password" type="password" name="password"&gt;
      &lt;/div&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="pass_conf"&gt;Confirm Password&lt;/label&gt;
      &lt;input id="pass_conf" type="password" name="pass_conf"&gt;
      &lt;/div&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="email"&gt;Email&lt;/label&gt;
      &lt;input id="email" type="text" name="email"&gt;
      &lt;/div&gt;
  
      &lt;div class="formElm"&gt;
      &lt;label for="about"&gt;About&lt;/label&gt;
      &lt;textarea id="about" cols="30" rows="5" name="about"&gt;Tell us about yourself&lt;/textarea&gt;
      &lt;/div&gt;
  
      &lt;input type="submit" name="submit" value="Register"&gt;
      &lt;/form&gt;
  
      or &lt;a href="index.php"&gt;Login&lt;/a&gt;
      &lt;/div&gt;
      &lt;/html&gt;
      &lt;?php
      }
      else
      {
      $first = protect($_POST['first']);
      $last = protect($_POST['last']);
      $username = protect($_POST['username']);
      $password = protect($_POST['password']);
      $pass_conf = protect($_POST['pass_conf']);
      $email = protect($_POST['email']);
      $about = protect($_POST['about']);
      $errors = array();
      $regex = "/^[a-z0-9]+([_\.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\.[a-z]{2,}$/i";
      if(!preg_match($regex, $email))
      {
        $errors[] = "E-mail is not in name@domain format!";
      }
  
      if(!$first || !$last || !$username || !$password || !$pass_conf || !$email || !$about)
      {
         $errors[] = "You did not fill out the required fields";
      }
  
      $sql = "SELECT * FROM `users` WHERE `username`='{$username}'";
      $query = mysql_query($sql) or die(mysql_error());
  
      if(mysql_num_rows($query) == 1)
      {
        $errors[] = "Username already taken, please try another";
      }
      if(count($errors) &gt; 0)
      {
        echo "The following errors occured with your registration";
        echo "&lt;font color=\"red\"&gt;";
        foreach($errors AS $error)
        {
          echo "&lt;p&gt;" . $error . "\n";
        }
        echo "&lt;/font&gt;";
        echo "&lt;a href=\"javascript:history.go(-1)\"&gt;Try again&lt;/a&gt;";
        //we use javascript to go back rather than reloading the page 
        // so the user doesn't have to type in all that info again.
      }
      else
      {
        $sql = "INSERT into `users`(`first`,`last`,`username`,`password`,`email`,`about`)
        VALUES ('$first','$last','$username','".md5($password)."','$email','$about');";
  
       $query = mysql_query($sql) or die(mysql_error());
       echo "Thank You for registering {$first}! Your username is {$username}";
       echo "&lt;a href=\"index.php\"&gt; Click here &lt;/a&gt; to Login";
      }
      }
  
  ?&gt;
  </code></pre>