title: redirect from one page to another using php
body: <p>I am making a webpage. Its user's form basically. I am taking username, password n email ID n checking if they already exist in the database or not.<br />
  If they exist i want to move to a next page showing 'username already exists' in case username is dere in DB or it will show 'You already have account on this id' in case email id matches. <br />
  this line will be followed by form. So can you please help me how to do it?<br />
  here's my code</p>
  
  <pre><code>&lt;?php
  $host = "localhost";
  $user = "root";
  $password = "";
  $database = "signin";
  $table = "userdetails";
  $userName = $_POST['userName'];
  $emailId = $_POST['emailID'];
  $password = $_POST['password'];
  $cnfPassword = $_POST['cnfPassword'];
  $con = mysql_connect($host, $user) or die(mysql_error());
  mysql_select_db($database, $con) or die(mysql_error());
  if ($password == $cnfPassword &amp;&amp; strlen($password) != 0) {
      echo "Your Password Matched\n";
      echo "&lt;br /&gt;";
  } else {
      echo "Please enter a valid password \n";
      echo "&lt;br /&gt;";
  }
  $result = mysql_query("SELECT * FROM `userdetails` WHERE `UserName`=\"$userName\"");
  $count = 0;
  while ($row = mysql_fetch_array($result)) {
      $count++;
      echo "UserID ".$row['UserID']."&lt;br /&gt;UserName: ".$row['UserName']."&lt;br /&gt;EmailID: ".$row['emailID']."\n";
  }
  if ($count == 0 &amp;&amp; $password == $cnfPassword &amp;&amp; strlen($password) != 0) {
      $query = "INSERT INTO userdetails (UserName,emailID,Password) VALUES('$userName','$emailId','$password')";
      $result = mysql_query($query);
      echo $result;
      echo "&lt;br /&gt;";
      echo "You ar welcomed\n";       
      echo "&lt;br /&gt;";
  } else {
      action("sign_up.php");
      echo "&lt;br /&gt;Username already exists\n";
      echo "&lt;br /&gt;";
  }
  ?&gt;
  </code></pre>