Petsmacker
08-28-2005, 01:52 AM
<?
$uname=$_COOKIE["uname"];
$pword=$_COOKIE["pword"];
if ($uname != '')
{
$dbuser="XXX";
$dbpword="XXX";
$dbname="XXX";
mysql_connect(localhost,$dbuser,$dbpword);
@mysql_select_db($dbname) or die( "Unable to select database");
$query="SELECT * FROM members WHERE uname='$uname'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$username=mysql_result($result,"uname");
$password=mysql_result($result,"pword");
if ($num == '1')
{
if (($uname == $username) && ($pword == $password))
{
$_SESSION['uname']="$uname";
} else {
echo "The Username/Password in your cookie does not match the Username/Password in our database<br><br>$uname --- $pword <br>$username --- $password";
}
} else {
echo "There are no records of your Username in the database";
}
?>
Basically this snippet of script
- Opens the cookies and gets the usernames and passwords
- If the cookie isn't empty, to open the database and get the information for that user
- When it has done that, to create a session with that Username.
HOWEVER, I've aded the <br><Br>$uname --- $pword bit myself to test what the database is outputting and it turns out that it outputs the ROW NUMBER for both $username and $password. I don't understand why it isn't outputting the usernames and passwords themselves, can anyone see why? I have a feeling it may have something to do with variables being called the same thing.
$uname=$_COOKIE["uname"];
$pword=$_COOKIE["pword"];
if ($uname != '')
{
$dbuser="XXX";
$dbpword="XXX";
$dbname="XXX";
mysql_connect(localhost,$dbuser,$dbpword);
@mysql_select_db($dbname) or die( "Unable to select database");
$query="SELECT * FROM members WHERE uname='$uname'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$username=mysql_result($result,"uname");
$password=mysql_result($result,"pword");
if ($num == '1')
{
if (($uname == $username) && ($pword == $password))
{
$_SESSION['uname']="$uname";
} else {
echo "The Username/Password in your cookie does not match the Username/Password in our database<br><br>$uname --- $pword <br>$username --- $password";
}
} else {
echo "There are no records of your Username in the database";
}
?>
Basically this snippet of script
- Opens the cookies and gets the usernames and passwords
- If the cookie isn't empty, to open the database and get the information for that user
- When it has done that, to create a session with that Username.
HOWEVER, I've aded the <br><Br>$uname --- $pword bit myself to test what the database is outputting and it turns out that it outputs the ROW NUMBER for both $username and $password. I don't understand why it isn't outputting the usernames and passwords themselves, can anyone see why? I have a feeling it may have something to do with variables being called the same thing.