title: Sign Up/Log In Form PHP MySQL
body: <p>Good day!</p>
  
  <p>I have been looking for various solutions on the web but I haven't passed by a single one to solve my problem</p>
  
  <p>Basically I have been making a login system with a registration feature, and everything is working well except when I try to register, it doesn't enter into the database that I have made. Then I tried inserting values into my table, and tried logging in, but all it does was log in even though I did the password wrong.</p>
  
  <p>Here's the database:</p>
  
  <pre><code>+----------+-------------+------+-----+---------+----------------+
  | Field    | Type        | Null | Key | Default | Extra          |
  +----------+-------------+------+-----+---------+----------------+
  | studID   | int(11)     | NO   | PRI | NULL    | auto_increment |
  | fname    | varchar(30) | NO   |     | NULL    |                |
  | lname    | varchar(30) | NO   |     | NULL    |                |
  | address  | varchar(80) | NO   |     | NULL    |                |
  | username | varchar(20) | NO   |     | NULL    |                |
  | password | varchar(20) | NO   |     | NULL    |                |
  +----------+-------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>index.html</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Welcome!&lt;/title&gt;
  &lt;style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="form1" method="post" action="login.php"&gt;
  &lt;div align="center"&gt;
  &lt;p&gt;&lt;img src="images/welcome.jpg" /&gt;&lt;/p&gt;
    &lt;table id="title"&gt;
      &lt;tr&gt;
        &lt;td&gt;Username:&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="username" /&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" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;input type="submit" name="submit" value="Log In" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
  &lt;p&gt;New here? &lt;a href="signup.php"&gt;Register!&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>login.php</p>
  
  <pre><code>&lt;?php
  include("db.php");
  
  session_start(); 
  
  $username=($_POST['username']);
  $password=($_POST['password']);
  
  $result=mysql_query("SELECT count(*) FROM student WHERE username='$username' and password='$password'");
  
  $count=mysql_fetch_array($result);
  
  if($count==0){
    session_register("username");
    session_register("password");
    header("location:success.php");
  } else {
    echo 'Wrong Username or Password! Return to &lt;a href="index.html"&gt;login&lt;/a&gt;';
    }
  ?&gt;
  </code></pre>
  
  <p>and db.php</p>
  
  <pre><code>&lt;?php  
      $conn = mysql_connect('localhost', 'root', 'ella');
       if (!$conn)
      {
       die('Could not connect: ' . mysql_error());
      }
      mysql_select_db("studrecord", $conn);
  ?&gt;
  </code></pre>
  
  <p>signup.php (it's quite long, will cut some unnecessary parts)</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Register&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="index.html"&gt;
    &lt;table id="title"&gt;
      &lt;tr&gt;
        &lt;td&gt;First Name:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="fname" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Last Name:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="lname" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Address:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="address" /&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" /&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" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;input type="submit" name="submit" value="Sign Up" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  
  &lt;?php
  if (isset($_POST['submit']))
      {      
      include 'db.php';
  
                      $fname=$_POST['fname'];
                              $lname=$_POST['lname'];                 
                      $address=$_POST['address'];
                      $username=$_POST['username'];
                      $password=$_POST['password'];
  
           mysql_query("INSERT INTO student(fname,lname,address,username,password) 
           VALUES ('$fname','$lname','$address','$username','$password')"); 
              }
  ?&gt;
  &lt;/...
  </code></pre>
  
  <p>Thank you in advance!</p>