I have a login system in my site. in which session starts when user login. when a user sign up his information is stored in userdb.php .now i want to store point of the user when he clicks link www.stackoverflow.com and save it to my database or userdb.php.and again display point. my sign up code are
<?php
if (session_id() == "")
{
session_start();
}
$database = './usersdb.php';
$success_page = './Inside.php';
$error_message = "";
if (!file_exists($database))
{
die('User database not found!');
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'signupform')
{
$newusername = $_POST['username'];
$newemail = $_POST['email'];
$newpassword = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$newfullname = $_POST['fullname'];
$code = 'NA';
if ($newpassword != $confirmpassword)
{
$error_message = 'Password and Confirm Password are not the same!';
}
else
if (!preg_match("/^[A-Za-z0-9_!@$]{1,50}$/", $newusername))
{
$error_message = 'Username is not valid, please check and try again!';
}
else
if (!preg_match("/^[A-Za-z0-9_!@$]{1,50}$/", $newpassword))
{
$error_message = 'Password is not valid, please check and try again!';
}
else
if (!preg_match("/^[A-Za-z0-9_!@$.' &]{1,50}$/", $newfullname))
{
$error_message = 'Fullname is not valid, please check and try again!';
}
else
if (!preg_match("/^.+@.+\..+$/", $newemail))
{
$error_message = 'Email is not a valid email address. Please check and try again.';
}
else
if (isset($_POST['captcha'],$_SESSION['random_txt']) && md5($_POST['captcha']) == $_SESSION['random_txt'])
{
unset($_POST['captcha'],$_SESSION['random_txt']);
}
else
{
$error_message = 'The entered code was wrong.';
}
$items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($items as $line)
{
list($username, $password, $email, $fullname) = explode('|', trim($line));
if ($newusername == $username)
{
$error_message = 'Username already used. Please select another username.';
break;
}
}
if (empty($error_message))
{
$file = fopen($database, 'a');
fwrite($file, $newusername);
fwrite($file, '|');
fwrite($file, md5($newpassword));
fwrite($file, '|');
fwrite($file, $newemail);
fwrite($file, '|');
fwrite($file, $newfullname);
fwrite($file, '|1|');
fwrite($file, $code);
fwrite($file, "\r\n");
fclose($file);
$subject = 'Your new account';
$message = 'A new account has been setup.';
$message .= "\r\nUsername: ";
$message .= $newusername;
$message .= "\r\nPassword: ";
$message .= $newpassword;
$message .= "\r\n";
$header = "From: webmaster@yourwebsite.com"."\r\n";
$header .= "Reply-To: webmaster@yourwebsite.com"."\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
$header .= "Content-Transfer-Encoding: 8bit"."\r\n";
$header .= "X-Mailer: PHP v".phpversion();
mail($newemail, $subject, $message, $header);
header('Location: '.$success_page);
exit;
}
}
?>
Please help me.....