Ok, please bear in mind that I have just written this in the last 5 minutes and I have not tested it
It is not very secure and does not check if the user does not enter an email address or an invalid email address. I am sure you can do that though 
Database table
Code:
CREATE TABLE `users` (
`ID` int(11) NOT NULL auto_increment,
`email` varchar(60) NOT NULL,
KEY `ID` (`ID`)
) ENGINE=MyISAM;
login.php
PHP Code:
<?php
include('dbconnect.php'); // connect to the database
if(isset($submit)) { // if user presses submit
$email = $_POST['email']; // grab posted email value
$sql = mysql_query("SELECT email FROM users WHERE email = '$email'"); // query database
$num_rows = mysql_num_rows($sql); // grab number of rows
if($num_rows <= 0) {
mysql_query("INSERT INTO users (email) VALUES ('$email')"); // add email address to database
session_start(); // start session
$_SESSION['email'] = $email; // add email address to session
header('Location: gallery.php'); // send user to gallery page
} elseif($num_rows > 0) {
session_start();
$_SESSION['email'] = $email;
header('Location: gallery.php');
}
}
?>
<html>
<head>
<title>Photo Login Page</title>
</head>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<input type="text" name="email" size="50" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
Add the following to the top of the gallery page and any other page that you want the user to have to use their email address to view
PHP Code:
<?php
header("Expires: Tue, 15 May 2001 10:00:01 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
session_start();
if(!isset($_SESSION['email'])) { // if there is no session
header('Location: login.php'); // send user to login page
exit();
}
?>
Hope this helps you
Bookmarks