I have to login twice, to login?
<p>my website has a login script, and for some reason you have to login, then it goes back to the login page and then you login again and its fine, it must be something to do with the login script, but not sure where...</p>

<pre><code>    &lt;?php
    $host="localhost"; // Host name
    $username=""; // Mysql username
    $password=""; // Mysql password
    $db_name=""; // Database name
    $tbl_name="members"; // Table name

   // Connect to server and select databse.
   mysql_connect("$host", "$username", "$password")or die("cannot connect");
   mysql_select_db("$db_name")or die("cannot select DB");

   // username and password sent from form
   $myusername=$_POST['myusername'];
   $mypassword=$_POST['mypassword'];

   // To protect MySQL injection (more detail about MySQL injection)
   $myusername = stripslashes($myusername);
   $mypassword = stripslashes($mypassword);
   $myusername = mysql_real_escape_string($myusername);
   $mypassword = mysql_real_escape_string($mypassword);

   $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and    password='$mypassword'";
   $result=mysql_query($sql);

   // Mysql_num_row is counting table row
   $count=mysql_num_rows($result);
   // If result matched $myusername and $mypassword, table row must be 1 row


   if($count){
        session_start();
       session_regenerate_id();
        $_SESSION['SESS_USERNAME'] = $myusername;
        $_SESSION['SESS_PASSWORD'] = $mypassword;
        session_write_close();
       header("location: login_success.php");
   }

   else 
  {
  include("loginhtml.html");
  } 
 ?&gt;
</code></pre>

<p>then the checklogin, (which is at the top of each page)</p>

<pre><code>          &lt;?php
          session_start();
          if(!isset($_SESSION['SESS_USERNAME']) || !isset($_SESSION['SESS_PASSWORD']) || (trim($_SESSION['SESS_USERNAME']) == '')) {
            //someone's not logged in
    header("location: index.php"); //it's suppose to actually be there
            exit();
          }
         ?&gt;
</code></pre>

<p>any ideas??</p>

<p>cheers</p>
