PHP login with MYSQL Question?
| From: | JeRRy | Date: | Fri, 18 Nov 2005 11:34:08 +0000 |
| Subject: | PHP login with MYSQL Question? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-40689@lists.php.net to get a copy of this message | ||
Hi,
Okay I created a user/pass login area. I created the following code. Now I want the secure area
to send a cookie to the users PC we can track so I can make multiple pages without the need for the
user to login to each page individually. I want to know what is the best method/code to use as a
cookie with the following code. Thanks for the help in advance!
<?
$password=$_POST['pass'];
mysql_connect ("localhost", "db_username", "db_password") or die
('My SQL Error: ' . mysql_error());
mysql_select_db ("db_dbname");
$stuff = mysql_query("SELECT * FROM
users WHERE
userName='".$userName."' AND
userPass='".$userPass."'") or die("MySQL Login Error:
".mysql_error());
if (mysql_num_rows($stuff) > 0) {
$row=mysql_num_rows($stuff);
echo "You are logged in to Admin as $userName <br> <small>Beta
Version</small><br><br>";
}
else{
echo ("<title>Incorrect</title><body bgcolor='black'
text='red' alink='blue' vlink='blue' link='blue'>
<center><br><br><br>Incorrect Password!<br><br><a
href='login.php'>try again</a></center> ");
}
?>
J
---------------------------------
____________________________________________________
---------------------------------
Do you Yahoo!?
Never miss an Instant Message - Yahoo! Messenger for SMS