http://www.phpwelt.de/
there are a lot of samples and code snippets, but try to do it yourselfe, its a good experiance if you have built your own loginsys 😉
what you will need is a table for the userdata. lets call it user
id name login password cookie
the fields ar defined as
id int unsigned index primary unique autoincrement not null
name varchar 50
login varchar 50
password varchar 50
cookie smalint 2
now you set up a form where the user can fill in login and password. if he submits the form you check it against the db and if this user exists, you welcome him with he's name.
sounds simple 😉
function for checking the login:
<?
if ($action=="login"){
mysql_connect (hostname', 'username', 'password' );
mysql_select_db (dbname);
$query="select * from user where (login='$login') and (password='$password')";
$result = mysql_query ($query);
if (($result)AND($row = mysql_fetch_array($result))) {
//do the action for logedin user
}
}
?>
form:
<form action="" method="post">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>Name</td>
<td><input type="text" name="login"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
</table>
<input type="hidden" name="action" value="login">
<input type="submit" name="send" value="Send">
</form>
now pasted together (not tested)
login.php
<?
if ($action=="login"){
$username=""; //set the initial value of username
mysql_connect (hostname', 'username', 'password' );
mysql_select_db (dbname);
$query="select * from user where (login='$login') and (password='$password')";
$result = mysql_query ($query);
if (($result)AND($row = mysql_fetch_array($result))) {
$username=$row["name"];
}
}
?>
<head>
</head>
<body>
<?
if($username=""){
?>
<form action="login.php" method="post">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>Name</td>
<td><input type="text" name="login"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
</table>
<input type="hidden" name="action" value="login">
<input type="submit" name="send" value="Send">
</form>
<?}else{?>
Welcome <?=$username?>
<?}?>
</body>
for this system you will need a mysql DB set up and running
have fun..