RE: [PHP-DB] PHP login with MYSQL Question?
| From: | Bastien Koert | Date: | Fri, 18 Nov 2005 12:31:19 +0000 |
| Subject: | RE: [PHP-DB] PHP login with MYSQL Question? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40690@lists.php.net to get a copy of this message | ||
$_SESSION is better than $_COOKIE ( more secure)
Bastien
From: JeRRy <jusa_98@yahoo.com>
To: php-db@lists.php.net
Subject: [PHP-DB] PHP login with MYSQL Question?
Date: Fri, 18 Nov 2005 22:34:08 +1100 (EST)
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