Page 1 of 1
Good Rigister code
Posted: Thu Apr 10, 2008 12:25 pm
by kusal
I'm looking for good register/login script for a website.
I have seen some popular .inc files for this with lot of security code
problem is that I cannot remember the name of the .inc file
can anyone help?
Thank you
Re: Good Rigister code
Posted: Thu Apr 10, 2008 12:30 pm
by Jade
The idea of a login is pretty simple. You'll need to have a form where the user can input their username and password. Then you'll have to check and see if that information is valid using a database or some other kind of validation method. Finally you'll need to set a session to keep track of the user's information as they navigate the website.
Code: Select all
<?php
session_start();
//login to database here
if ($_POST['submit'])
{
//check database to see if user exists
if ($userexists)
{
$_SESSION['user'] = $userid;
session_write_close();
header("Location: account.php");
exit;
}
//otherwise you can generate some error message here
}
?>
<form action="#" method="post">
Username: <input type="text" name="username" /><br/><br/>
Password: <input type="password" name="pass" />
<center><input type="submit" name="submit" value="Login" /></center>
</form>