Problem with user registration
Posted: Thu Apr 12, 2012 8:52 am
getting these errors on my register.php page:
Warning: include(.public_html/user.inc.php) [function.include]: failed to open stream: No such file or directory in /home/zub/public_html/init.inc.php on line 25
Warning: include() [function.include]: Failed opening '.public_html/user.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zub/public_html/init.inc.php on line 25
Fatal error: Call to undefined function email_exists() in /home/zub/public_html/register.php on line 31
here is the code for user.inc.php
Warning: include(.public_html/user.inc.php) [function.include]: failed to open stream: No such file or directory in /home/zub/public_html/init.inc.php on line 25
Warning: include() [function.include]: Failed opening '.public_html/user.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zub/public_html/init.inc.php on line 25
Fatal error: Call to undefined function email_exists() in /home/zub/public_html/register.php on line 31
here is the code for user.inc.php
<?php
//check if the given email address exist in the database
function email_exists($email){
$email = mysql_real_escape_string($email);
$total = mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `email` = '{$email}'");
return (mysql_result($total, 0) =='1') ? true : false;
}
//checks if the given email and password combination is valid
function valid_credentials($email, $pass){
$email = mysql_real_escape_string($email);
$pass = sha1($pass);
$total = mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `email` = '{$email}' AND `password` = `{$pass}`");
return (mysql_result($total, 0) =='1') ? true : false;
}
//adds a user to the database
function add_user($firstname, $lastname, $pass, $email){
$email = mysql_real_escape_string(htmlentities($email));
$pass = sha1($pass);
$random = rand(23456789, 98765432);
$date=date("Y-m-d");
mysql_query("INSERT INTO `users` (`first_name`, `last_name, `password`, `email`, `date`, `random`, `0`)
VALUES ('{$firstname}', '{$lastname}', '{$pass}', '{$email}', '$date', $random, 0)");
$lastid = mysql_insert_id();
$webmaster = "Zubscriber <activate@Zubscriber.com>";
$headers = "From: $webmaster";
$subject = "Activate Your Account";
$server = "SERVER1.LESULTRA.COM";
ini_set ("SMTP", $server);
$body = "Hi $firstname,\n\n
To activate your Zubscriber account please click the following link: \n\n
http://Zubscriber.com/activate.php?id=$ ... random\n\n
Thanks for joining the crew, \n
The Zubscriber team";
mail($emailaddress, $subject, $body, $headers);
}
?>
here is init.inc.php: <?php
//check if the given email address exist in the database
function email_exists($email){
$email = mysql_real_escape_string($email);
$total = mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `email` = '{$email}'");
return (mysql_result($total, 0) =='1') ? true : false;
}
//checks if the given email and password combination is valid
function valid_credentials($email, $pass){
$email = mysql_real_escape_string($email);
$pass = sha1($pass);
$total = mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `email` = '{$email}' AND `password` = `{$pass}`");
return (mysql_result($total, 0) =='1') ? true : false;
}
//adds a user to the database
function add_user($firstname, $lastname, $pass, $email){
$email = mysql_real_escape_string(htmlentities($email));
$pass = sha1($pass);
$random = rand(23456789, 98765432);
$date=date("Y-m-d");
mysql_query("INSERT INTO `users` (`first_name`, `last_name, `password`, `email`, `date`, `random`, `0`)
VALUES ('{$firstname}', '{$lastname}', '{$pass}', '{$email}', '$date', $random, 0)");
$lastid = mysql_insert_id();
$webmaster = "Zubscriber <activate@Zubscriber.com>";
$headers = "From: $webmaster";
$subject = "Activate Your Account";
$server = "SERVER1.LESULTRA.COM";
ini_set ("SMTP", $server);
$body = "Hi $firstname,\n\n
To activate your Zubscriber account please click the following link: \n\n
http://Zubscriber.com/activate.php?id=$ ... random\n\n
Thanks for joining the crew, \n
The Zubscriber team";
mail($emailaddress, $subject, $body, $headers);
}
?>
here is my register.php:<?php
include('init.inc.php');
if (isset($_POST['first_name'], $_POST['last_name'], $_POST['password'], $_POST['retypepass'], $_POST['email'], $_POST['confirmemail']))
{
if(empty($_POST['first_name']) || empty($_POST['last_name'])){
$erros[] = 'Please enter your first name and your last name!';
}
if(empty($_POST['password']) || empty($_POST['retypepass'])){
$errors[] = 'Password fields cannot be empty';
}
if($_POST['password'] !== $_POST['retypepass']){
$erros[] = 'Passwords do not match!';
}
if(empty($_POST['email']) || empty($_POST['confirmemail'])){
$errors[] = 'Please enter and confirm you email address!';
}
if($_POST['email'] !== $_POST['confirmemail']){
$errors[] = 'Email addresses do not match!';
}
if(email_exists($_POST['email'])){
$errors[] = 'A user has already registered with that email address!';
}
if(empty($errors) === TRUE)
{
add_user($_POST['first_name'], $_POST['last_name'], $_POST['password'], $_POST['email'] );
$_SESSION['first_name'] = htmlentities($_POST ['first_name']);
header('Location: members.php');
die();
}
}
?>
What have I done wrong here?