Forum Moderators: open
if(isset($_POST['login']))
{
//connect to database
if ($link = mysql_connect('localhost', '#*$!', '#*$!'))
{
// select the database that will be used
mysql_select_db("#*$!") or die("An error as occurred. Please contact the site administrator.");
//set post variables
$username = $_POST['loginUserID'];
$password = $_POST['loginPassword'];
// makes sure fields are completed
if(!$_POST['loginUserID'] ¦!$_POST['loginPassword'])
{
echo "Please enter the username and/or password";
}
$check = mysql_query("SELECT * FROM members WHERE username = '".$_POST['loginUserID']."'")or die(mysql_error());
//Gives error if user dosen't exist
$check2 = mysql_num_rows($check);
while($info = mysql_fetch_array( $check ))
{
//gives error if the password is wrong
if ($_POST['loginPassword']!= $info['passwd'])
{
die('Incorrect password, please try again.');
}
}
//redirect to member home page
header("Location:http://www.flaschattys.com/members.htm");
//create cookie
setcookie("user", $username); /* Expires in a week */
}
}