Login Code Help

Hi Guys,

I can’t figure out what the problem is here.

code:


<?php
ob_start();
session_start();
include("inc/inc-dbconnection.php");
include("inc/inc-online.php");
include("inc/inc-functions.php");
include("inc/inc-header.php");
?>
<div class="fcp-main-content-area">	
 <div class="fcp-breadcrumb">
  <ul>
	 <li><a href="index.php">Home</a></li> >>
	 <li><a href="javascript:history.go(-1)">Previous Page</a></li> >>
	 <li>Login in to your account.</li>
	</ul>
</div>
<?php
if (isset($_POST['submitLogin']))
{

   // Errors array()
   $errors = array();
   
   // POST vars
   $user = $_POST['user'];
   $pass = $_POST['pass'];
   
   // Potential errors 
   // Empty fields
   if (empty($user) || empty($pass))
   {
      $errors[] = "You never filled in all the fields above.";
   }
   
   // Does user exist?
   $qU = "SELECT * FROM `fso_users` WHERE `user_email`='$user' AND `user_password`='$pass' LIMIT 1";
   $rU = mysql_query($qU);  

   if (mysql_num_rows($rU) < 1)
   {   
      $errors[] = "We don't recognise those login details, have you typed them correctly?"; 
   }
    
   // Count the errors
   if (count($errors > 0))
   {
       // Display the errors
       print "<div id=\\"error\\">";
     
       foreach($errors as $error)
       {
       
          print "<b>></b> $error<br />";
       
       }
     
       print "</div>";
     
   } else {

      /*// Update the login timer and redirect
      $timer = mysql_query("UPDATE `fso_users` SET `user_last_login`=NOW() WHERE `user_email`='$user' AND `user_password`='$pass'");
      
      // Array()
      $aU = mysql_fetch_array($rU);
      
      // $_SESSION[''];
      $_SESSION['loggedIn'] = 1; 
      $_SESSION['user_id']  = $aU['user_id'];

      // Lastly redirect to the account page
      header("Location: account.php"); 
      ob_clean();*/
      print "No errors...";     
   } 

}
?>
<div id="div-regForm">
<div class="form-title">Log In</div>
<div class="form-sub-title">Login & see your points score!</div>
<form id="regForm" action="login.php" method="post">
<table>
  <tbody>
  <tr>
    <td><label for="fname">Email:</label></td>
    <td><div class="input-container"><input name="user" id="user" type="text" /></div></td>
  </tr>
  <tr>
    <td><label for="lname">Password:</label></td>
    <td><div class="input-container"><input name="pass" id="pass" type="text" /></div></td>
  </tr>
  <tr>
  <td> </td>
  <td><input type="submit" class="greenButton" name="submitLogin" value="Login" />
</td>
  </tr> 
  </tbody>
</table>
</form>
</div>  
<?php
include("inc/inc-footer.php");
?>

The errors print out fine (if there is any) but i can’t get to this block print “No errors…”; this is where the user would be redirected to the account.php but it never executes.

any help would be appreciated

thanks guys

Graham

if (count($errors > 0))
should be
if (count($errors) > 0)

ah thanks mate :slight_smile:

Graham