mobile browsers' can't login to my site

Posted by imin on Stack Overflow See other posts from Stack Overflow or by imin
Published on 2010-04-06T10:39:42Z Indexed on 2010/04/06 10:43 UTC
Read the original article Hit count: 201

Filed under:
|
|

i've tested my site on 2 phone models using the 'generic' browser that came with the phone, but sadly, everytime I tried to login, it will return me back to my index page.

here's my login code

    <form name='login' method='POST' action='authentication.php'>
<table border=0 cellpadding=2>
<tr><td>Login:</td><td></td></tr>
<tr><td>E-mail: </td><td><input type=text name='email' id='email' size=20 maxlength="200"></td></tr>
<tr><td>Password: </td><td><input type=password name='password' id='password' size=20 maxlength="100"></td></tr>
<tr><td></td><td><input type=submit value='Login'></td></tr>
</table></form>

and here's the authentication.php (snippet)

$currentUserEmail = $_POST["email"];
$currentUserPwd = md5($_POST["password"]);
$stmt = $dbi->prepare("select status from users where email=? and pwd=?");
$stmt->bind_param('ss', $currentUserEmail,$currentUserPwd); 
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$isUserAvailable = mysqli_stmt_num_rows($stmt);
$stmt->bind_result($getUserStatus);
$stmt->execute() or die (mysqli_error());
$stmt->store_result();
$stmt->fetch();
$stmt->close();

if($isUserAvailable > 0){
    if ($getUserStatus == "PENDING") {
        $userIsLoggedIn = "NO";
        $registeredUser = "NO"; 
        unset($userIsLoggedIn);
        setcookie("currentMobileUserName", "", time()-3600);
        setcookie("currentMobileUserEmail", "", time()-3600);
        setcookie("currentMobileSessionID", "", time()-3600);
        setcookie("currentMobileUID", "", time()-3600);
        header('Location: '.$config['MOBILE_URL'].'/index.php?error=2&email='.$currentUserEmail);
    }elseif (($getUserStatus == "ACTIVE") || ($getUserStatus == "active")){ //means successfully logged in

        //set the cookie

        setcookie("currentMobileUserName", $currentUserName, $expire);
        setcookie("currentMobileUserEmail", $currentUserEmail, $expire);
        setcookie("currentMobileSessionID", $getGeneratedMobileUSID, $expire);
        setcookie("currentMobileUID", $currentUID, $expire);
        $userIsLoggedIn = "YES";
        $registeredUser = "YES";


        $result = $stmt->execute() or die (mysqli_error($dbi));

        if ($caller == "indexLoginForm"){
            header('Location: '.$config['MOBILE_URL'].'/home.php');
        }else{

            header('Location: '.$config['MOBILE_URL'].'/home.php');

        }


    }

}else{
    $userIsLoggedIn = "NO";
    $registeredUser = "NO"; 
    unset($userIsLoggedIn);
    setcookie("currentMobileUserName", "", time()-3600);
    setcookie("currentMobileUserEmail", "", time()-3600);
    setcookie("currentMobileSessionID", "", time()-3600);
    setcookie("currentMobileUID", "", time()-3600);
    header('Location: '.$config['MOBILE_URL'].'/index.php?error=1');

}

The only way I can access my mobile site is by using opera mini. Just FYI, both the 'generic browsers' i tested my site with supports cookie (at least this is what the browser settings said).

thanks

© Stack Overflow or respective owner

Related posts about mobile

Related posts about authentication