Jump to content

[SOLVED] problem with login page/ possibly to do with cookies


simon551

Recommended Posts

I cleared all cookies in Firefox and now my log in page doesn't work. It works in IE, but not in firefox. I don't know if this is a php (my) problem or if it is something to do with the browser. Any ideas?

 

posting my code in case it helps

<?php require_once('Connections/conn_org.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['UserName'])) {
  $loginUsername=$_POST['UserName'];
  $password=$_POST['Password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "userlogin/Index_.php";
  $MM_redirectLoginFailed = "userlogin/login.php";
  $MM_redirecttoReferrer = true;


  mysql_select_db($database_conn_org, $conn_org);
  $LoginRS__query=sprintf("SELECT UserName, Password FROM users WHERE UserName='%s' AND Password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $conn_org) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

//set some more cookies
	mysql_select_db($database_conn_org, $conn_org);
	$query_rsLoginDetails = ("SELECT users.UserName, users.Password, users.EmpID, tblemployees.GroupID, tblgroups.DivisionID, Managers.EmpID AS MgrID, concat(tblEmployees.EmpFName,' ',tblEmployees.EmpLName ) AS Name FROM tblemployees Inner Join tblgroups ON tblemployees.GroupID = tblgroups.GroupID Inner Join users ON tblemployees.EmpID = users.EmpID Inner Join tblemployees AS Managers ON tblemployees.TeamID = Managers.EmpID WHERE users.UserName= '$loginUsername' AND users.Password= '$password'");
	$rsLoginDetails = mysql_query($query_rsLoginDetails, $conn_org) or die(mysql_error());
	$row_rsLoginDetails = mysql_fetch_assoc($rsLoginDetails);
	$totalRows_rsLoginDetails = mysql_num_rows($rsLoginDetails);

	  setcookie("empid", "".$row_rsLoginDetails['EmpID']  ."", time()+(60*60*24*10), "/", "", 0);


	  setcookie("divisionid", "".$row_rsLoginDetails['DivisionID']  ."", time()+(60*60*24*10), "/", "", 0);


	  setcookie("mgrid", "".$row_rsLoginDetails['MgrID']  ."", time()+(60*60*24*10), "/", "", 0);
//end custom code, go back to dw standard login
    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="login" name="login" method="POST" action="<?php echo $loginFormAction; ?>">
  <table width="100%" border="0" cellspacing="0" cellpadding="6">
    <tr>
      <td width="25"> </td>
      <td colspan="2" class="smallText"> </td>
    </tr>
    <tr>
      <td width="25"> </td>
      <td >USER NAME</td>
      <td ><input name="UserName" type="text" id="UserName" size="40"></td>
    </tr>
    <tr>
      <td width="25"> </td>
      <td >PASSWORD</td>
      <td ><input name="Password" type="password" id="Password" size="40"></td>
    </tr>
    <tr>
      <td width="25"> </td>
      <td > </td>
      <td ><input name="Login" type="submit" id="Login" value="Login"></td>
    </tr>
</table>
</form>
</body>
</html>

 

Thanks in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.