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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.