<?
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password = $_POST['password'];
$password_encrypt = md5($password);
$user_address = $_POST['user_address'];
/* Lets strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$address = stripslashes($address);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Username is a required field. Please enter it below.<br />";
}
if(!$password){
echo "Password is a required field. Please enter it below.<br />";
}
if(!$address){
echo "Address is a required field. Please enter it below.<br />";
}
include 'join_form.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been registered by another member in our database. Please submit a different Email address!<br />";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been registered by another member in our database. Please choose a different Username!<br />";
unset($username);
}
include 'index.htm'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
// Enter info into the Database.
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date, decrypted_password, birth, address)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$password_encrypt', now(), '$password'), '$birth', '$address'") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
$activatepath = "includes/activate.php?id=$userid&code=$password_encrypt";
// Let's mail the user!
$subject = "Membership request at $sitename";
$message = "Dear $first_name $last_name,
You are now registered at our website, $sitepath !
To activate your membership, please login here: $sitepath$activatepath
Once you activate your membership, you will be able to login with the following information:
Username: $username
Password: $password
Please keep this username and password in a location that is easily accessible by you.
Thanks!
$sitename
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>
You were right about the brackets, must have overlooked it. However, it did not fix the error. I don't think the page even go that far in the code before getting the error.
Warning: Cannot send session cache limiter - headers already sent (output started at /home/httpd/vhosts/ticketblasters.com/httpdocs/includes/register.php:26) in /home/httpd/vhosts/ticketblasters.com/httpdocs/includes/join_form.php on line 2
Do you know what "cannot send session cache limiter - headers already sent" means?
I did your "Sessions with a Minor User Logins" tutorial. I ended up placing the "ob_start();" in each page thinking that it would fix it, but it did not. I also checked out the other link you gave.
I could not figure out where I was getting my code out of order. This is what it looks like now:
<?
ob_start();
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password = $_POST['password'];
$address = $_POST['address'];
/* Lets strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$address = stripslashes($address);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Username is a required field. Please enter it below.<br />";
}
if(!$password){
echo "Password is a required field. Please enter it below.<br />";
}
if(!$address){
echo "Address is a required field. Please enter it below.<br />";
}
include 'join_form.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been registered by another member in our database. Please submit a different Email address!<br />";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been registered by another member in our database. Please choose a different Username!<br />";
unset($username);
}
include 'index.htm'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
$password_encrypt = md5($password);
// Enter info into the Database.
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date, decrypted_password, address)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$password_encrypt', now(), '$password', '$address'") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
$activatepath = "includes/activate.php?id=$userid&code=$password_encrypt";
// Let's mail the user!
$subject = "Membership request at $sitename";
$message = "Dear $first_name $last_name,
You are now registered at our website, $sitepath !
To activate your membership, please login here: $sitepath$activatepath
Once you activate your membership, you will be able to login with the following information:
Username: $username
Password: $password
Please keep this username and password in a location that is easily accessible by you.
Thanks!
$sitename
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>