Good Rigister code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kusal
Forum Newbie
Posts: 14
Joined: Mon Oct 22, 2007 12:12 pm

Good Rigister code

Post 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
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Good Rigister code

Post 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>
 
Post Reply