php session problem in IE 6.0

chhangru_at_gmail.com
Date: 02/17/05


Date: 17 Feb 2005 11:17:35 -0800

i have this log in script from a book that uses session variable to
track the user.. everything works fine in firefox but in IE 6.0 the
page only refreshes and the user can be authenticated... i have tried
most of the solutions posted on the web.. but to no avail.. if anyone
can look at the code.. and help me..

thanks.. kelli

here are the scripts..
// stories.php
<?php
// Listing 26.5
// stories.php Is the Interface for Writers to Manage Their Stories

include('include_fns.php');
session_start();

if (!check_auth_user()) {
?>
<form action="login.php" method="post">
<table border="0">
<tr>
  <td>Username</td>
  <td><input size="16" name="username"></td>
</tr>
<tr>
  <td>Password</td>
  <td><input size="16" type="password" name="password"></td>
</tr>
</table>
<input type="submit" value="Log in">
</form>
<?php
}
else {
  $conn = db_connect();

  $w = get_writer_record($HTTP_SESSION_VARS['auth_user']);

  print 'Welcome, '.$w['full_name'];
  print ' (Logout)';
  print '<p>';

  $sql = 'select * from stories where writer = \''.
         $HTTP_SESSION_VARS['auth_user'].'\' order by created desc';
  $result = mysql_query($sql, $conn);

  print 'Your stories: ';
  print mysql_num_rows($result);
  print ' (Add new)';
  print '</p><br /><br />';

  if (mysql_num_rows($result)) {
    print '<table>';
    print '<tr><th>Headline</th><th>Page</th>';
    print '<th>Created</th><th>Last modified</th></tr>';
    while ($qry = mysql_fetch_array($result)) {
      print '<tr>';
      print '<td>';
      print $qry['headline'];
      print '</td>';
      print '<td>';
      print $qry['page'];
      print '</td>';
      print '<td>';
      print date('M d, H:i', $qry['created']);
      print '</td>';
      print '<td>';
      print date('M d, H:i', $qry['modified']);
      print '</td>';
      print '<td>';
      if ($qry['published'])
        print '[Published '.date('M d, H:i', $qry['published']).']';
      else {
        print '[edit] ';
        print '[<a
href="delete_story.php?story='.$qry['id'].'">delete</a>] ';
        print '[<a
href="keywords.php?story='.$qry['id'].'">keywords</a>]';
      }
      print '</td>';
      print '</tr>';
    }
    print '</table>';
  }

}
?>

///////login.php
<?php
session_start();

include('include_fns.php');
session_register("auth_user");

if ( (!isset($HTTP_POST_VARS['username'])) ||
(!isset($HTTP_POST_VARS['password'])) ) {
  print 'You must enter your username and password to proceed';
  exit;
}

$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];

if (login($username, $password)) {
  $HTTP_SESSION_VARS['auth_user'] = $username;

  header('Location: '.$HTTP_SERVER_VARS['HTTP_REFERER']);
}
else {
  print 'The password you entered is incorrect';
  exit;
}

?>

// user_auther_fns.php
<?php
session_start();
function login($username, $password)
// check username and password with db
// if yes, return true
// else return false
{
  // connect to db
  $conn = db_connect();
  if (!$conn)
    return 0;

  $result = mysql_query("select * from writers
                         where username='$username'
                         and password ='$password'");
  if (!$result)
     return 0;

  if (mysql_num_rows($result)>0)
     return 1;
  else
     return 0;
}

function check_auth_user($auth_user)
// see if somebody is logged in and notify them if not
{
  global $HTTP_SESSION_VARS;
  if (isset($HTTP_SESSION_VARS['auth_user']))
    return true;
  else
    return false;
}

?>



Relevant Pages

  • Re: PHP.exe closing on exit
    ... All I want to do is test PHP scripts on my Windows XP client machine. ... I can't disable 'close on exit', ... > your script exits, the PHP shell that launched it has no purpose, so it ...
    (comp.lang.php)
  • Session losing variables?
    ... I have a script start.php and a second script proceed.php ... <?PHP ... // Strings match, so open logfile, exit if this fails. ...
    (comp.lang.php)
  • Re: multipul ip ban
    ... Can u give me any good sites that I can learn more about php? ... with the ip ban script? ... > /* open file for readonly */ ... > /* page and exit the script */ ...
    (alt.php)
  • Re: PHP.exe closing on exit
    ... > doesn't seem to have the traditional options of an MS-DOS program. ... your script exits, the PHP shell that launched it has no purpose, so it ... I'd expect a language interpreter to exit once I'm done with it ...
    (comp.lang.php)
  • Re: [PHP] PHP console script vs C/C++/C#
    ... My script is taking a longer time to execute than I want. ... I prefer to write in PHP because that is what I know best. ... This is why I am thinking about rewriting my whole script in a C language. ... Perhaps there are different methods I could be using to speed up execution. ...
    (php.general)