Jump to content


Photo

Problems with login script.


  • Please log in to reply
4 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 31 July 2006 - 12:09 PM

Hey Guys,
I've used the same method for my login script before,
Yet all of a sudden it is deciding not to work. The problem is...

I have a login script and it works, but when I add the script to
check if the user is banned, or activated their account i get this
error:

"please enter a username" which is one of my errors at the top of the script.

My codes together are; (below are the two separate scripts):
<?PHP session_start(); ?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="keywords" content="Eumod, Eurpean modified cars, modded, mod, customized">
<meta name="description" content="Eumod is a discussion wbesite and fitting company. we're proud of our services and expanding.">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="style.css">
<title>EZone Logging in</title>
</head>

<body>
<?PHP
include("../db/db.php"); 
$user = $_POST['user']; 
$pass = $_POST['pass']; 
if ($user == NULL){ 
	die('<p class="text">You must enter in a username.</p>');
} 
if ($pass == NULL){ 
	die('<p class="text">You must enter in a password.</p>');
}

		//AUTHORIZE BAN
	$sql = mysql_query("SELECT adm_ban,pri_active FROM accounts WHERE usr_user='".strtolower($_POST['user'])."' AND usr_pass='".md5($_POST['pass'])."'");
	while( $data = mysql_fetch_array($sql, MYSQL_NUM))
		{
		$ban = $data[0];
		$act = $data[1];
			if($ban == "y")
				{
				echo '<meta http-equiv="REFRESH" content="0;ULR=../index.php?category=ezone&page=suspended">';
				exit;
				}
			if($act != y)
				{
				echo '<meta http-equiv="REFRESH" content="0;ULR=../index.php?category=ezone&page=inactive">';
				exit;
				}
		}

$user_query = mysql_query("SELECT * FROM accounts WHERE usr_user='".strtolower($user)."' AND usr_pass='".md5($pass)."'"); 

$num_users = mysql_num_rows( $user_query ); 
if (!$num_users){
	die('<p class="text">Wrong combination or user does not exist!<BR><a href="javascript:history.back(1)">Go Back</a></p>'); 
} else { 
	while($user = mysql_fetch_assoc( $user_query)){ 
		$_SESSION['EumodUK'] = true; 
		$_SESSION['user'] = $user;
	
		echo '<meta http-equiv="refresh" content="0;URL=../index.php">';
	} 
}
?>
</body>

</html>



My code is:
<?PHP session_start(); ?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="keywords" content="Eumod, Eurpean modified cars, modded, mod, customized">
<meta name="description" content="Eumod is a discussion wbesite and fitting company. we're proud of our services and expanding.">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="style.css">
<title>EZone Logging in</title>
</head>

<body>
<?PHP
include("../db/db.php"); 
$user = $_POST['user']; 
$pass = $_POST['pass']; 
if ($user == NULL){ 
	die('<p class="text">You must enter in a username.</p>');
} 
if ($pass == NULL){ 
	die('<p class="text">You must enter in a password.</p>');
}

$user_query = mysql_query("SELECT * FROM accounts WHERE usr_user='".strtolower($user)."' AND usr_pass='".md5($pass)."'"); 

$num_users = mysql_num_rows( $user_query ); 
if (!$num_users){
	die('<p class="text">Wrong combination or user does not exist!<BR><a href="javascript:history.back(1)">Go Back</a></p>'); 
} else { 
	while($user = mysql_fetch_assoc( $user_query)){ 
		$_SESSION['EumodUK'] = true; 
		$_SESSION['user'] = $user;
	
		echo '<meta http-equiv="refresh" content="0;URL=../index.php">';
	} 
}
?>
</body>

</html>

My ban code is:
//AUTHORIZE BAN
	$sql = mysql_query("SELECT adm_ban,pri_active FROM accounts WHERE usr_user='".strtolower($_POST['user'])."' AND usr_pass='".md5($_POST['pass'])."'");
	while( $data = mysql_fetch_array($sql, MYSQL_NUM))
		{
		$ban = $data[0];
		$act = $data[1];
			if($ban == "y")
				{
				echo '<meta http-equiv="REFRESH" content="0;ULR=../index.php?category=ezone&page=suspended">';
				exit;
				}
			if($act != y)
				{
				echo '<meta http-equiv="REFRESH" content="0;ULR=../index.php?category=ezone&page=inactive">';
				exit;
				}
		}


#2 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 31 July 2006 - 12:15 PM

Well, the $_POST['user'] information is lost with the refresh...
I'm just a guy who likes to code for fun...

#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 31 July 2006 - 12:17 PM

what do you mean? :/ What refresh

#4 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 31 July 2006 - 12:18 PM

when i put the code under "ban" in that login script it says unknown user.
when it's removed it works perfectly.

But I don't see how considering there is NOT a refresh script unless the user:
- is banned,
- Inactive or logged in successfully :/

#5 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 31 July 2006 - 12:24 PM

shoud the if($act != y) be if($act != "y") ?

I'm just a guy who likes to code for fun...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users