can't login using IE6

Discussion in 'PHP' started by asmon, Jul 19, 2008.

  1. #1
    Since i can't really express myself in English, i'll just say i have the same issue this guy has
    http://www.webmasterworld.com/php/3304214.htm

    "
    I have a php application which allows members to log in and their information is saved and retrieved from a MySQL database.

    People cannot log in using Internet Explorer 6.0, but have no problem logging in with Firefox and Internet Explorer 7.0.

    This is the only cookie I use on the site. Does anyone else know of this problem with php Cookies and IE 6? "

    here's the page where i check if log in is ok

    
    <?php
    include("cgi-bin/db_config.php");
    $conn = mysql_connect ($db_host, $db_user, $db_password);
    $db_select = mysql_select_db("$db_name",$conn);
    if (!$db_select){
    die ("Could not select the database: <br />". mysql_error());
    }
    
    //if the login form is submitted
    if (isset($_POST['submit'])) {
    
    // makes sure they filled it in
    if(!$_POST['username'] | !$_POST['pass']) {
    die('You did not fill in a required field.');
    }
    // checks it against the database
    
    if (!get_magic_quotes_gpc()) {
    $_POST['email'] = addslashes($_POST['email']);
    }
    $check = mysql_query("SELECT * FROM player_table WHERE username = '".$_POST['username']."'")or die(mysql_error());
    
    //Gives error if user dosen't exist
    $check2 = mysql_num_rows($check);
    if ($check2 == 0) {
    die('That user does not exist in our database.
    <a href=register.php>Click Here to Register</a>');
    }
    while($info = mysql_fetch_array( $check ))
    {
    $_POST['pass'] = stripslashes($_POST['pass']);
    $info['password'] = stripslashes($info['password']);
    
    
    //gives error if the password is wrong
    if ($_POST['pass'] != $info['password']) {
    die('Incorrect password, please try again.');
    }
    
    else
    {
    if (isset($_POST['remember']))
    
     {
    
    // if login is ok then we add a cookie
    $_POST['username'] = stripslashes($_POST['username']);
    $hour = time() + 3600;
    setcookie(loguser, $_POST['username'], $hour);
    setcookie(logpass, $_POST['pass'], $hour);
    $date = DATE('Y-m-d');
    $update = "UPDATE users SET last_date='$date' WHERE username='$_POST[username]'";
    
    mysql_query($update, $conn);
    //then redirect them to the members area
    session_start();
    $_SESSION['username']=$_POST['username'];
    $_SESSION['pass']=$_POST['pass'];
    header("Location: index.php");
    }
     else
     {
    
    
    session_start();
    $_SESSION['username']=$_POST['username'];
    $_SESSION['pass']=$_POST['pass'];
    header("Location: index.php");
    
    
    
    
    }}}
    }
    else
    {
    echo("error 101");
    }
    
    ?>
    
    PHP:

    and that's the code i put in other pages to check if i'm logged

    
    if(isset($_COOKIE['loguser']))
    {
    $username = $_COOKIE['loguser'];
    $pass = $_COOKIE['logpass'];
    }
    else if(isset($_SESSION['username']))
    {
    $username = $_SESSION['username'];
    $pass= $_SESSION['pass'];
    //checks if something was selected
    }
    if (isset($username))
    {
    $check = mysql_query("SELECT * FROM $playerstable WHERE username = '$username'")or die(mysql_error());
    if($info = mysql_fetch_array( $check ))
    {  $passs= $info['password'];
    
    //if the cookie has the wrong password
    if ($pass != $passs)
    {die(mysql_error());
    }
    
    
    //otherwise they are shown the logged area
    else
    {
    
    PHP:
     
    asmon, Jul 19, 2008 IP
  2. Talker

    Talker Notable Member

    Messages:
    2,795
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    210
    #2
    I had the same issue once and i disabled the cookies!!
    Lolz, i know that's not what you should do. i just didnt have to look into all this.

    Please let me know if you find a solution to this.
     
    Talker, Jul 19, 2008 IP
  3. ceweqsakti

    ceweqsakti Banned

    Messages:
    1,192
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why dont u use firefox or opera? But your problem same with me. Go to ie option,privacy,add site n enter that site after that allow
    Try it
     
    ceweqsakti, Jul 19, 2008 IP
  4. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    i have both firefox and ie7, the problem is not me being unable to login
    but other people who enter the website with IE6 and unable to log in.
     
    asmon, Jul 19, 2008 IP
  5. ceweqsakti

    ceweqsakti Banned

    Messages:
    1,192
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ah the problems are from peoples who want to login.hahaha say to them to use ie7 or ff 2 higher
     
    ceweqsakti, Jul 19, 2008 IP
  6. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    lol, but there must be something i can do to fix the problem, no? :|
     
    asmon, Jul 19, 2008 IP
  7. ceweqsakti

    ceweqsakti Banned

    Messages:
    1,192
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If you can login.so there isnt problem right?
    No need to change
     
    ceweqsakti, Jul 19, 2008 IP
  8. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    almost half of the web users still use IE6, that's a huge problem..
     
    asmon, Jul 19, 2008 IP
  9. Talker

    Talker Notable Member

    Messages:
    2,795
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    210
    #9
    He means the cookies dont save in IE6... am i right?
     
    Talker, Jul 19, 2008 IP
  10. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #10
    yep, even tho some ie6 users can
     
    asmon, Jul 19, 2008 IP
  11. chanakya

    chanakya Peon

    Messages:
    361
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Use sessions instead of cookie , or check if users are using ie6 and use session for ie6 users
     
    chanakya, Jul 19, 2008 IP
  12. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #12
    $hour = time() + 3600;
    setcookie(loguser, $_POST['username'], $hour);
    setcookie(logpass, $_POST['pass'], $hour);
    PHP:
    Make sure you set your cookies properly. It seems you forgot to quotes around your loguser and logpass.

    
    $hour = time() + 3600;
    setcookie('loguser', $_POST['username'], $hour);
    setcookie('logpass', $_POST['pass'], $hour);
    
    PHP:
     
    php-lover, Jul 19, 2008 IP
  13. Talker

    Talker Notable Member

    Messages:
    2,795
    Likes Received:
    108
    Best Answers:
    0
    Trophy Points:
    210
    #13

    Good Catch.. did you manage to get it fixed using the updated code by php=lover?
     
    Talker, Jul 22, 2008 IP