Jump to content

login form does not work in IE


mallen

Recommended Posts

My login form works ok in Firefox but fails in IE. It sends the user to the index page. Any ideas?

 

<?php 
session_start();

$query= "SELECT id, email, password, status FROM `members` "
."WHERE `email`='".$_POST["email"]."' "
."AND `password`= '".$_POST["password"]."' "
."LIMIT 1";

$result= mysql_query($query)
OR die( mysql_error() );

  if ( mysql_num_rows($result) == 1 ) {
  // retrieve the resultset as an associative array
  $userRecord= mysql_fetch_assoc($result);
  $_SESSION['id']= $userRecord['id'];
  $_SESSION['status']= $userRecord['status'];

  // redirect based on the $userRecord['status'] value here
switch ($userRecord['status']) {
  case 1:
    $location= "page1.php";
    break;
  case 2:
    $location= "page2.php";
    break;
case 3:
    $location= "page3.php";
    break;
  
}
header("Location: $location");  
}    
?> 
HTML HERE.....

<form action="" method="post">

   <label>Email
   <input type="text" name="email" id="email" />
   </label>
   <label>Password
   <input type="password" name="password" id="password" />
   </label>
   <label>
   <input type="submit" name="submit" id="submit" value="submit" />
   </label>
</form>


Link to comment
https://forums.phpfreaks.com/topic/99773-login-form-does-not-work-in-ie/
Share on other sites

From what I see, as soon as the page loads, it tries to load post variables that I assume would come from the form at the bottom? Well, that won't work because the query runs before the form is displayed, unless I'm wrong about the form at the bottom supplying the data used in the query. Then, since there is no post variables, I'm assuming $userRecord['status'] is NULL so the switch cause doesn't assign $location to anything and the header call redirects to index because of this.

 

I could be WAY off base as I only skimmed it because I'm at work... Actually, I should be working right now

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.