...

View Full Version : help with login script



andrewsheldon98
02-07-2003, 04:51 PM
hi there.

below is a simple register.php script that registers user name and password in a table.

but i dont know how to create a login script, can someone help.

(if login successful to go to welcome.php)



<?php
function showheader ($title) {
?>
<HTML>
<HEAD>
<TITLE><?php echo $title ?></TITLE>
</HEAD>
<BODY>
<CENTER>
<?php
}

function showfooter () {
?>
</CENTER>
</BODY>
</HTML>
<?php
}

mysql_connect("localhost", "scpacouk", "w761730e");
mysql_select_db("scpacouk");

if ($Password == $Password2) {
$user = mysql_query("SELECT * FROM users WHERE (Name='$Name')");
if (mysql_num_rows($user) > 0) {
showheader("User Name Taken !");
?>
User Name <B><?php echo $Name ?></B> Is already Taken.
<?php
showfooter();
}
else {
$user = mysql_query("INSERT INTO users VALUES ('$Name','$Password')");
setcookie("site_user", $Name, time() + 31536000, "/");
setcookie("site_pass", $Password, time() + 31536000, "/");
showheader("Registration Success!");
?>
You have registered.<BR>
User Name: <?php echo $Name ?>
<BR>
Password: <?php echo $Password ?>
<?php
showfooter();
}
}
else {
showheader("Registration Error!");
?>
Your Two Passwords Did Not Match
<?php
showfooter();
}
?>

Spookster
02-07-2003, 06:09 PM
You will want to get into using sessions as well once they have logged in.

http://www.webmasterbase.com/article/319

http://hotwired.lycos.com/webmonkey/00/05/index2a.html?tw=programming



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum