Problem logging in

Started on the old forum in September 2011 · view the original in the archive · old links redirect here

7 replies · 441 views · started 15 years ago · 1 min read

3 participants
s3nzo Developer · 156 posts #1

Guys i created a script and i am able to login with every browser even old phones like motorola v360 but when i try to login with opera mini i just can't, what confuses me is it also returns no errors, what could be the reason?

subzero Super moderator Fellow · 3,954 posts #2

Are you using session like

session_start();

to

$user = $_SESSION['user']=$user();

if so you will need to send the user session id as well 😉

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

subzero Super moderator Fellow · 3,954 posts #4

No the point of using session is to hide your code.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

arnage Lead · 811 posts #5

Check the names of dynamic pages, or post code simply.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
s3nzo Developer · 156 posts #6

login.php

<?php
	require	'inc/head.inc';

	if(isset($_SESSION['id']))
			header('Location:index.php');
	if(!isset($_POST['loginName']))
	{	

		require	'inc/header.inc';

		if(isset($_SESSION['errors']))
		{
			if(is_array($_SESSION['errors']))
			{
				foreach($_SESSION['errors'] as $error)
					print	$error.'<br>';
			}
			else
				print	$_SESSION['errors'];
		}
						$forms->login();
			unset($_SESSION['errors']);
	}

	else
		{
			$_SESSION['loginName']	=	mysql_real_escape_string(htmlentities(stripslashes($_POST['loginName'])));
			$pass		=	mysql_real_escape_string(trim(htmlentities(stripslashes(md5($_POST['pass']))));
			$errors	=	array();
			if(empty($_SESSION['loginName']))
				$errors	=	'Login name can not be empty';
			if(empty($pass))
				$errors	=	'Password is required';
				
			$sql	=	"SELECT password FROM users WHERE loginName	=	'{$_SESSION['loginName']}' AND password	=	'{$pass}'";
				$query	=	mysql_query($sql, $con);
				
		if((mysql_num_rows($query)) != 1)
			$errors	=	'Your details do not match';
					
		if(count($errors))
			{
				unset($_POST['loginName']);
				$_SESSION['errors']	=	$errors;
				header('Location:login.php');
			}
	else
			{
			session_regenerate_id();
			$sql	=	"SELECT * FROM users WHERE loginName	=	'{$_SESSION['loginName']}'";
			$query2	=	mysql_query($sql, $con);
			$result	=	mysql_fetch_array($query2);
			$_SESSION['nick']		=	$result['nick'];
			$_SESSION['id']			=	$result['id'];
			if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
				$_SESSION['ip']			=	$_SERVER['HTTP_X_FORWARDED_FOR'];
			else
				$_SESSION['ip']			=	$_SERVER['REMOTE_ADDR'];
			$updateIP	=	mysql_query("UPDATE	users	SET	ip	=	'{$_SESSION['ip']}'	WHERE id	=	'{$_SESSION['id']}'");
			if(empty($_SESSION['nick']))
				header('Location:profile.php');
			else
				header('Location:index.php');
			}
		}
	require	'inc/foot.inc';
?>

And here is index.php

<?php
	require	'inc/head.inc';
	require	'inc/header.inc';	

	if(isset($_SESSION['errors']))
		if(is_array($_SESSION['errors']))
		{
            foreach($_SESSION['errors'] as $error)
			print	'<div class=dl2>'.$error.'</div>';
			unset($_SESSION['errors']);
		}
		else
		{
			print	'<div class=dl2>'.$_SESSION['errors'].'</div>';
			unset($_SESSION['errors']);
		}
		if(isset($_SESSION['nick']))
			{
				print	'<form action="insert.php" method=post>
							<div class=dl>Chat | <a href="">Check messages</a></div>
							<input type=text size=text name=msg maxlength=200>
							<input class=button type=submit value=Send>
						</form>';
			}
		else
			if(isset($_SESSION['id']) && !isset($_SESSION['nick']))
			print	'<div class=dl><a href=more.php>Update</a> your nick to chat</div>';
			
			$sql	=	"SELECT * FROM chatroom ORDER BY date DESC LIMIT 0, 25";
			$query	=	mysql_query($sql, $con);
			if((mysql_num_rows($query)) < 1)
			if(!isset($_SESSION['id']))
				print	'something';
			else
				print	'something else';
			$style	=	0;
			while($result	=	mysql_fetch_array($query))
			{
				require	'inc/emos.inc';
				if(is_int($style/2))
					print '<div class=conv><a href=user.php?nick='.$result['nick'].'>'.$result['nick'].'</a> : '.$chatmsg.'</div>';
				else
					print '<div class=conv1><a href=user.php?nick='.$result['nick'].'>'.$result['nick'].'</a> : '.$chatmsg.'</div>';
				$style++;
			}
			
		$msql	=	"SELECT * FROM users ORDER BY signup_date DESC LIMIT 0,1";
		if($mquery	=	mysql_query($msql))
			while($mrows	=	mysql_fetch_array($mquery))
				{
					print	'<div class=dl>Newest member : <a href=user.php?nick='.$mrows['nick'].'>'.$mrows['nick'].'</a></div>';
				}
			
		require	'inc/foot.inc';
?>
subzero Super moderator Fellow · 3,954 posts #7

i have notice when i builded my site using session it didn't like me using session id but using session username works on all type of browsers but netfront that not my problem thou as its do with there cache

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

arnage Lead · 811 posts #8

For a quick fix try this:

<?php
    require    'inc/head.inc';

    if(isset($_SESSION['id']))
            header('Location:index.php'); exit(); // <- exit here
    if(!isset($_POST['loginName']))
    {    

        require    'inc/header.inc';

        if(isset($_SESSION['errors']))
        {
            if(is_array($_SESSION['errors']))
            {
                foreach($_SESSION['errors'] as $error)
                    print    $error.'<br/>';
                    break; // <- stop loop
            }
            else
                print    $_SESSION['errors'];
        }
                        $forms->login();
            unset($_SESSION['errors']);
    }

    else
        {
            $_SESSION['loginName']    =    mysql_real_escape_string(htmlentities(stripslashes($_POST['loginName'])));
            $pass        =    mysql_real_escape_string(trim(htmlentities(stripslashes(md5($_POST['pass']))));
            $errors    =    array();
            if(empty($_SESSION['loginName']))
                $errors    =    'Login name can not be empty';
            if(empty($pass))
                $errors    =    'Password is required';
                
            $sql    =    "SELECT password FROM users WHERE loginName    =    '{$_SESSION['loginName']}' AND password    =    '{$pass}'";
                $query    =    mysql_query($sql, $con);
                
        if(mysql_num_rows($query) != 1) // was: if((mysql_num_rows($query)) != 1)
            $errors    =    'Your details do not match';
                    
        if(count($errors))
            {
                unset($_SESSION['loginName']);// was: unset($_POST['loginName']);
                $_SESSION['errors']    =    $errors;
                header('Location:login.php');
            }
    else
            {
            session_regenerate_id();
            $sql    =    "SELECT * FROM users WHERE loginName    =    '{$_SESSION['loginName']}'";
            $query2    =    mysql_query($sql, $con);
            $result    =    mysql_fetch_array($query2);
            $_SESSION['nick']        =    $result['nick'];
            $_SESSION['id']            =    $result['id'];
            if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
                $_SESSION['ip']            =    $_SERVER['HTTP_X_FORWARDED_FOR'];
            else
                $_SESSION['ip']            =    $_SERVER['REMOTE_ADDR'];
          @mysql_query("UPDATE    users    SET    ip    =    '{$_SESSION['ip']}'    WHERE id    =    '{$_SESSION['id']}'");
// was: $updateIP    =    mysql_query("UPDATE    users    SET    ip    =    '{$_SESSION['ip']}'    WHERE id    =    '{$_SESSION['id']}'");
            if(empty($_SESSION['nick']))
                header('Location:profile.php');
            else
                header('Location:index.php');
            }
        }
    require    'inc/foot.inc';
?>

If not, u will have to recode whole login and error handling. Its not good to cut corners in this part by skipping {}, unchecked globals, creating errors array and counting it if there is no error...

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close