Hey there,
i have this login code, works great, but i need to have it get the user_id from the db and set is as $logged_in_userid
here is the code that i have:
PHP Code:<?PHP
$links = "<A HREF='main.php'>Click here to proceed to the main page</A><BR>
You Will Be Redirected In 2 Seconds.<br>
<META HTTP-EQUIV='refresh' content='2;URL=http://customer.homtek.net/main.php'>";
if ($username && $pass) {
if ($logged_in_customer == $username) {
echo $username.", you are already logged in.<BR><BR>";
echo $links;
exit;
}
$dbh = mysql_connect ("localhost", "homtek_dclamp", "moiola") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("homtek_homtek");
$result = mysql_query("SELECT * FROM customer_login WHERE username = '".$username."'
AND password = PASSWORD('".$pass."')");
if (!$result) {
echo "Sorry, there has been an error. Please try again, or contact technical support.";
exit;
}
if (mysql_num_rows($result) > 0) {
$logged_in_customer = $username;
session_register("logged_in_customer");
echo "Welcome, ".$logged_in_customer.". <BR><BR>";
echo $links;
exit;
} else {
echo "<font color=red>Invalid login. Please try again.</font><BR><BR>";
}
} else if ($username || $pass) {
echo "<font color=red>Please fill in both fields.</font><BR><BR>";
}
?>
<FORM METHOD=POST ACTION="login.php">
Your username:
<INPUT NAME="username" TYPE=TEXT MAXLENGTH=20 SIZE=20>
<BR>
Your password:
<INPUT NAME="pass" TYPE=PASSWORD MAXLENGTH=10 SIZE=10>
<BR>
<INPUT TYPE=SUBMIT VALUE="Login">
</FORM>




Reply With Quote