hi
There are also other good TUTORIALS at http://php.about.com/
for example
Articles & Resources
Using the PHP MAIL function
Using the PHP MAIL function to send form data to email
Using Cookies with PHP
Cookies are used to store information about a user on their computer.
Basic PHP Sessions
A tutorial explaining the basics of using sessions in PHP
Execute PHP from a .html File
How to execute PHP code in a file with a .html extension
Introduction to Preg in PHP
Understanding the preg_grep, preg_match, preg_match_all, preg_replace, and preg_split functions and how to use them on your PHP website
PHP Login Script
http://php.about.com/od/finishedphp1/ss/php_login_code.htm
Loooks as a good basic script for login, with Cookies and MySQL database.
Normally we would store user email and maybe IP-address, too,
but this script uses only 3 fields: ID, username, password
CREATE TABLE users (
ID MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(60),
password VARCHAR(60)
)
Here is how test is done at page, if user is logged in or not
<?php
// Connects to your Database
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}
//otherwise they are shown the admin area
else
{
echo "Admin Area<p>";
echo "Your Content<p>";
echo "<a href=logout.php>Logout</a>";
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>