Jump to content

Login only works in firefox?


Zero767

Recommended Posts

<?php
  // process the script only if the form has been submitted
  if (array_key_exists('login', $_POST)) {
  include('includes/corefuncs.php');
  include('includes/connection.inc.php');
  // clean the $_POST array and assign to shorter variables
  nukeMagicQuotes();
  $username = trim($_POST['username']);
  $pwd = trim($_POST['pwd']);
  // connect to the database as a restricted user
  $conn = dbConnect('query');
  // prepare username for use in SQL query
  $username = mysql_real_escape_string($username);
  // get the username's details from the database
  $sql = "SELECT * FROM users WHERE username = '$username'";
  $result = mysql_query($sql);
  $row = mysql_fetch_assoc($result);
  // use the salt to encrypt the password entered in the form
  // and compare it with the stored version of the password
  // if they match, set the authenticated session variable 
  if (sha1($pwd.$row['salt']) == $row['pwd']) {
    $_SESSION['authenticated'] = 'Dufe Zero';
}
  // if no match, destroy the session and prepare error message
  else {
    $_SESSION = array();
session_destroy();
$error = 'Invalid username or password';
}
  // if the session variable has been set, redirect
  if (isset($_SESSION['authenticated'])) {
// get the time the session started
$_SESSION['start'] = time();
$_SESSION['name'] = $_POST['username'];
echo "<meta http-equiv=\"refresh\" content=\"1; url=http://www.naruto-chronicles.com/index.php\" /> "; 
exit;
}
  }
?>
<!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>Login</title>
</head>
<body>
<?php
if (isset($error)) {
  echo "<p>$error</p>";
  }
elseif (isset($_GET['expired'])) {
?>
  <p>Your session has expired. Please log in again.</p>
  <p>
  <?php } ?>
  <?php
if (!isset($_SESSION['authenticated'])) {
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
  Register | Lost Password?</a>
  <input name=\"username\" type=\"text\" class=\"userpassfield\" value=\"Username\" size=\"18\" maxlength=\"20\" id=\"username\" />
  <input name=\"pwd\" type=\"password\" class=\"userpassfield\" value=\"Password\" size=\"18\" maxlength=\"20\" id=\"pwd\" />
  <input name=\"login\" type=\"image\" class=\"loginbutton\" value=\"Login\" src=\"images/login_button.jpg\" />
</form>";
  }
  else {
echo 'Hey, welcome back '.$_SESSION['name'].'! <form id="logoutForm" name="logoutForm" method="post" action="">
    <input name="logout" type="submit" id="logout" value="Log out" />
</form>';
}
?>

 

There is the script, it is setup as an include file.

At the top of the script put in this line:

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>

this will tell you what is being POSTed from the from to your script. I have a feeling your problem is the image button you're using. FF will return the name of the button as being set along with the x/y position as name_x & name_y, MSIE will only return the x/y position.

 

Ken

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.