Jump to content

Problems with login script.


xyn

Recommended Posts

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):
[code]<?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>[/code]



My code is:
[code]<?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>[/code]

My ban code is:
[code]//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;
}
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/16096-problems-with-login-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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