title: PHP Code Notice: Undefined variable: password in C:\xampp\htdocs\myfiles\login.php on line 51 you must enter your password?
body: <p>The question I am asking has been asked <a href="https://stackoverflow.com/questions/21366281/php-login-system-error-on-line-51">here</a> but was asked pretty badly and resulted in the problem not being resolved. What the guy that asked that question is experiencing is exactly what I am experiencing, I assume he is following the same <a href="http://www.youtube.com/watch?v=hAkKC8DKN9A" rel="nofollow noreferrer">YouTube tutorial</a> as me. Anyway here is all of the PHP / HTML code I have written to far:</p>
  
  <pre><code>&lt;?php
  session_start();
  ?&gt;
  
  &lt;?php
  $form = "&lt;form action='./login.php' method='post'&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Username:&lt;/td&gt;
  &lt;td&gt;&lt;input type='text' name='user' /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;td&gt;Password:&lt;/td&gt;
  &lt;td&gt;&lt;input type='password' name='password' /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type='submit' name='loginbtn'  value='Login'/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/form&gt;";
  
  if ($_POST ['loginbtn']){
  $user = $_POST['user'];
  $user = $_POST['password'];
  
  
  if ($user){ 
  if ($password){ 
  echo "$user - $password &lt;hr /&gt; $form";
  }
  else
  echo "you must enter your password $form";
  
  }
  else
  echo "you must enter your username $form";
  
  }
  else
  echo $form;
  
  ?&gt;
  </code></pre>
  
  <p>I've tried adding a variable to <code>if ($user){</code> and <code>if ($password){</code> but that did nothing. Anyone know what the issue could be?</p>