sir pannels
10-25-2002, 11:01 PM
hey,
im trying to get the id form a users table here in mysql/php...
the script works fine. checks username and password etc
and then use a meta refresh to send the id to the next page. tho it just seems to not exstract or print the id at all.. as you`ll see.
<?php
#login.php
#ensure both form fields have entries
if( (!$username) || (!$password) )
{
header("Location:$HTTP_REFERER");
exit();
}
#connect to MySQL
$conn=@mysql_connect("localhost", "", "")
or die("Could not connect");
#select the specified database
$rs = @mysql_select_db("GAME", $conn)
or die("Could not select database");
#create the query
$sql="select * from user where username='$username' and password ='$password'" ;
#execute the query
$rs=mysql_query($sql,$conn)
or die("Could not execute query");
#get number of rows that match username and password
$num = mysql_num_rows($rs);
#if there is no match go back to log in page
if($num==0)
{
header("Location:loginerror.htm");
exit();}
else
{
#otherwise user is authenticated
$msg = "<h3>Loggin you in $username ...</h3>";
}
?>
<?php
echo("<html><head><title>Log-In blah blah meta be be soon..</title><meta http-equiv='refresh' content='1;
URL=inside.php?id=$id'></head><body>");
?>
<?php echo($msg); ?>
</body></html>
is it cuz the php tag has been closed and opened again? cuz i changed it so it was like this...
#otherwise user is authenticated
$msg = "<h3>Loggin you in $username ...</h3>";
}
echo("<html><head><title>Log-In blah blah meta be be soon..</title><meta http-equiv='refresh' content='1;
URL=inside.php?id=$id'></head><body>");
?>
but that just errored..
anyway any ideas?
thanks
P:thumbsup:
im trying to get the id form a users table here in mysql/php...
the script works fine. checks username and password etc
and then use a meta refresh to send the id to the next page. tho it just seems to not exstract or print the id at all.. as you`ll see.
<?php
#login.php
#ensure both form fields have entries
if( (!$username) || (!$password) )
{
header("Location:$HTTP_REFERER");
exit();
}
#connect to MySQL
$conn=@mysql_connect("localhost", "", "")
or die("Could not connect");
#select the specified database
$rs = @mysql_select_db("GAME", $conn)
or die("Could not select database");
#create the query
$sql="select * from user where username='$username' and password ='$password'" ;
#execute the query
$rs=mysql_query($sql,$conn)
or die("Could not execute query");
#get number of rows that match username and password
$num = mysql_num_rows($rs);
#if there is no match go back to log in page
if($num==0)
{
header("Location:loginerror.htm");
exit();}
else
{
#otherwise user is authenticated
$msg = "<h3>Loggin you in $username ...</h3>";
}
?>
<?php
echo("<html><head><title>Log-In blah blah meta be be soon..</title><meta http-equiv='refresh' content='1;
URL=inside.php?id=$id'></head><body>");
?>
<?php echo($msg); ?>
</body></html>
is it cuz the php tag has been closed and opened again? cuz i changed it so it was like this...
#otherwise user is authenticated
$msg = "<h3>Loggin you in $username ...</h3>";
}
echo("<html><head><title>Log-In blah blah meta be be soon..</title><meta http-equiv='refresh' content='1;
URL=inside.php?id=$id'></head><body>");
?>
but that just errored..
anyway any ideas?
thanks
P:thumbsup: