title: Undefined Index - PHP MySQL
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/q/302296/">strange php error</a><br>
    <a href="https://stackoverflow.com/q/476426/">Submit an HTML form with empty checkboxes</a><br>
    <a href="https://stackoverflow.com/q/746396/">PHP form checkbox and undefined index</a>  </p>
  </blockquote>
  
  
  
  <p>Some reason I am getting undefined index errors in the following code.  Any help would be appreciated. Here are the errors I am Recieving</p>
  
  <pre><code>Notice: Undefined index: username in C:\xampp\htdocs\register.php on line 5
  Notice: Undefined index: password in C:\xampp\htdocs\register.php on line 6
  Notice: Undefined index: firstname in C:\xampp\htdocs\register.php on line 7
  Notice: Undefined index: surname in C:\xampp\htdocs\register.php on line 8
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>&lt;?php
  mysql_connect("localhost", "root", "") or die(mysql_error()); 
  
   mysql_select_db("clubresults") or die(mysql_error()); 
     $username = $_POST['username'];
     $password = md5($_POST['password']);
     $firstname = $_POST['firstname'];
     $surname = $_POST['surname'];
  
     $sql = "INSERT INTO members (Username, Password, Firstname, Surname) VALUES ($username, $password, $firstname, $surname);";
  
     mysql_query($sql);
  
  ?&gt;
  
  &lt;html&gt;
          &lt;div class="content"&gt;
          &lt;center&gt;
          &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
               &lt;table border="0"&gt;
               &lt;tr&gt;&lt;td colspan=2&gt;&lt;h1&gt;Register&lt;/h1&gt;&lt;/td&gt;&lt;/tr&gt; 
               &lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;&lt;td&gt;
               &lt;input type="text" name="username" maxlength="60"&gt;
               &lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;
               &lt;input type="password" name="password" maxlength="10"&gt;
               &lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;Firstname:&lt;/td&gt;&lt;td&gt;
               &lt;input type="text" name="firstname" maxlength=210"&gt;
               &lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;Surname:&lt;/td&gt;&lt;td&gt;
               &lt;input type="text" name="surname" maxlength=210"&gt;
               &lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;th colspan=2&gt;&lt;input type="submit" name="submit" 
              value="Register"&gt; &lt;/th&gt;&lt;/tr&gt; &lt;/table&gt;
           &lt;/form&gt;
           &lt;/center&gt;
           &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>