title: Creating login page with a student ID mysql and php
body: <p>i have created a login page where a student is able to register using username, password and email. I have created a table which contains all the students ID. So when a students registers they have to enter a correct ID which has to match the table in order for them to register. I was wondering how can i do this. I am using php and mysql. </p>
  
  <pre><code>f(isset($_POST["submit"])){ `if(!empty($_POST['user']) &amp;&amp; !empty($_POST['pass']) &amp;&amp; !empty($_POST['email'])) {
  
  $user=$_POST['user'];
  </code></pre>
  
  <p>$pass=$_POST['pass'];</p>
  
  <pre><code>$email=$_POST['email'];
    $con=mysql_connect('localhost','root','') or die(mysql_error());
  </code></pre>
  
  <p>mysql_select_db('user_registration') or die("cannot select DB");</p>
  
  <pre><code>query=mysql_query("SELECT * FROM login WHERE username='".$user."'");
  </code></pre>
  
  <p>$numrows=mysql_num_rows($query); if($numrows==0)</p>
  
  <pre><code>$sql="INSERT INTO login(username,password,email) VALUES('$user','$pass', '$email')";
  </code></pre>
  
  <p>$result=mysql_query($sql);</p>
  
  <pre><code>if($result){ echo "Account Successfully Created"; } else {
  </code></pre>
  
  <p>echo "Failure!";</p>
  
  <pre><code>else { echo "That username already exists! Please try again with another.";
  
  
  else { echo "All fields are required!";
  </code></pre>
  
  <p>i have not included the student ID part as i am unsure </p>