View Single Post
Old June 17th, 2006, 01:51 PM  
Awesome Poster
Just...Will's Forum Picture
Join Date: November 19, 2004
Location: Bout a half hour west of Cleveland, OH
Age: 26
Gender: Male
Default Re: PHP help, please.

My administrative "panel" will be much more secure; this is just so people can login to submit content. I have been running it on a test page, and it always takes the "Die" road or, if it's not there, shows an error.

Edit: I posted it on PHP Freaks, and this is what they gave me and which works beautifully.
$connid = mysql_connect ('localhost' , 'DBUSER' , 'DBPASS');
mysql_select_db ("DB");
// make sure you escape any user input
$name = mysql_real_escape_string($_POST['name']);
$pass = mysql_real_escape_string($_POST['password']);
// select the username and password that match $name and $pass limit the query by 1
$sql = "SELECT `username`, `password` FROM users WHERE `username`='$name' AND `password`='$pass' LIMIT 1";
$result = mysql_query ($sql, $connid) or die("Unable to find username/password in database.");
// check that the query returned 1 result, if it did its a successful login!
if(mysql_num_rows($result) == 1)
    setcookie ("lap", "$name", time() + 3600);
    echo "Login Successful! Your username is $name. You will remain logged in for one hour. You may click the logout button to end your session early.";
else  // not successful!
    echo "Login failed.";
echo $name;


Je vais t'aime toujours.
Meme si tu ne m'aimes pas.
Rappeles-tu toujours ca.

Last edited by Just...Will; June 18th, 2006 at 01:47 AM.
Just...Will is offline