Login not working in IE
Posted: Wed Nov 16, 2005 1:54 am
Hi everyone, I am pretty new to php, so forgive any foolish mistakes! The code below is for a simple login/authentication script, works fine in Netscape and Firefox, but no joy in Explorer 5.5 or 6 . PHP version is 4.4.1 .
thanks in advance fro any help,
anthony
Code: Select all
<?php
session_start();
if (isset($_POST['submit2'])) {
// Check if the form has been submitted.
ob_start();
require_once ('mysql_connect.php'); // Connect to the database.
if (empty($_POST['username'])) { // Validate the username.
$u = FALSE;
} else {
$u = escape_data($_POST['username']);
}
if (empty($_POST['password'])) { // Validate the password.
$p = FALSE;
} else {
$p = escape_data($_POST['password']);
}
if ($u && $p) { // If everything's OK.
// Query the database.
//first get the date of registration from the database
$query = "SELECT username, first_name,registration_date,term FROM users WHERE username='$u' AND password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
if ($row) { // A match was made. The next few lines check that the registration has not expired
if ($row[term] == 'six') {$interval = 6;} else {$interval = 12;}
$query = "SELECT PERIOD_DIFF(now(),registration_date) WHERE username='$u' AND password=PASSWORD('$p')";
$result = @mysql_query ($query);
if ($result < $interval) {
// Start the session, register the values & redirect.
$_SESSION['first_name'] = $row['first_name'];
$_SESSION['username'] = $row['username'];
ob_end_clean(); // delete the buffer
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
exit();
}
else { header ("Location:reg_expired.php");exit();}
}
mysql_close(); // Close the database connection.
} else { // If everything wasn't OK, finsish the session
$_SESSION['username'] = NULL;
$_SESSION['first_name'] = NULL;
unset($_SESSION['username']);
unset($_SESSION['first_name']);
}
} // End of SUBMIT conditional.
ob_end_flush();
?>thanks in advance fro any help,
anthony