Guest_imported
New member
- Jan 1, 1970
- 0
Hi, I was wondering if anyone knew what's wrong with the script at the bottom of the page.
The problem is I have two tables with the following structure:-
bands_tbl:
-id
-user_id
members_tbl:
-uid
-username
-password
and the values $user_name, $user_password and $band_id are sent from a form to the coding below but it doesn't seem to work even when the correct information is given. The variable $band_id is the $id value from the bands_tbl and the other two variables explain themselves.
If anyone could help i'd be greatful. Thanx
<?
require("../config.inc.php"
;
$db = mysql_connect($host,$login,$pass);
mysql_select_db($base,$db);
$query = mysql_query("SELECT user_id FROM bands_tbl WHERE id = '$band_id'"
;
while ($record = mysql_fetch_object($query))
{
$user_id = $record->user_id;
}
$query2 = mysql_query("SELECT * FROM members_tbl WHERE uid = '$user_id' AND username = '$user_name' AND password = '$user_password'"
;
$results = mysql_num_rows($query2);
if ($results == '1')
{
session_start();
session_register('band_id');
session_register('user_name');
header('LOCATION: index.php');
}
else
{
echo '<font face="Verdana" size="2">Wrong Username or Password</font>';
include('login.php');
exit;
}
mysql_close($db);
?>
The problem is I have two tables with the following structure:-
bands_tbl:
-id
-user_id
members_tbl:
-uid
-username
-password
and the values $user_name, $user_password and $band_id are sent from a form to the coding below but it doesn't seem to work even when the correct information is given. The variable $band_id is the $id value from the bands_tbl and the other two variables explain themselves.
If anyone could help i'd be greatful. Thanx
<?
require("../config.inc.php"
$db = mysql_connect($host,$login,$pass);
mysql_select_db($base,$db);
$query = mysql_query("SELECT user_id FROM bands_tbl WHERE id = '$band_id'"
while ($record = mysql_fetch_object($query))
{
$user_id = $record->user_id;
}
$query2 = mysql_query("SELECT * FROM members_tbl WHERE uid = '$user_id' AND username = '$user_name' AND password = '$user_password'"
$results = mysql_num_rows($query2);
if ($results == '1')
{
session_start();
session_register('band_id');
session_register('user_name');
header('LOCATION: index.php');
}
else
{
echo '<font face="Verdana" size="2">Wrong Username or Password</font>';
include('login.php');
exit;
}
mysql_close($db);
?>