Login Scripts?
- Skit-666
-
Skit-666
- Member since: Nov. 4, 2001
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
I Need a ogin Script like the one for NG
Could someone please tell me it
- Cheesemold
-
Cheesemold
- Member since: Mar. 16, 2001
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
At 1/6/02 06:48 AM, Skit_666 wrote: I Need a ogin Script like the one for NG
Could someone please tell me it
I don't know the exact coding, but what you'd do, is have a mysql database, have it load the right varibles, and then when they type in the user name, that would tell the database which user account to get the password varible from, then have the password varible be like $password, and then password that the user enters be $passwordcompare, and if($passwordcompare == $password){ echo("login successful"); /* and anything else you want to happen when login successful(set their cookies, yadda yadda) */ } else { echo("password did not match username") } I'm sure there is an easier way to do this, but i'm not that much of a programmer.
- Noxi0us
-
Noxi0us
- Member since: Nov. 3, 2000
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
the PHP script for authenticating a user looks like this. it uses a MySQL database to access the username and password and check they are correct. This is merely a guide and the html forms plus creating the databse/table is all up to you.
<?
//to add a user to the database
if ((!$f_name) || (!$l_name) || (!$username) || (!$password)) {
header("Location: http://localhost/show_adduser.html");
exit;
}
$db_name = "testDB";
$table_name = "auth_users";
$connection = @mysql_connect("localhost", "admin", "pass") or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "INSERT INTO $table_name (f_name, l_name, username, password) VALUES ("$f_name", "$l_name","$username",password("$password"))";
$result = mysql_query($sql,$connection) or die("Couldn't execute query.");
?>
*******************************************************
<?
//to check the database for correct password/username
if ((!$username) || (!$password)) {
header("Location: http://localhost/show_login.html");
exit;
}
$db_name = "testDB";
$table_name = "auth_users";
$connection = @mysql_connect("localhost", "admin", "pass") or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "SELECT * FROM $table_name WHERE username = "$username" AND password = password("$password")";
$result = mysql_query($sql) or die ("Can't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
$msg = "Congratulations, you're authorized!";
} else {
header("Location: http://whatever/show_login.html");
exit;
}
?>

