-
Register form
I have a page and followed a tutorial and everything worked fine but I needed to add some things and now it wont work. When I go to register and type nothing in it goes to the error page telling me I didnt fill so and so in. I get the same thing when I fill everything in.
here's the register.php
Code:
<?
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$address1 = $_POST['address1'];
$town_city = $_POST['town_city'];
$state_county = $_POST['state_county'];
$zip_postcode = $_POST['zip_postcode'];
$security_question = $_POST['security_question'];
$security_answer = $_POST['security_answer'];
$username = $_POST['username'];
$password = $_POST['password'];
$confirm_password = $_POST['password'];
/* Let's 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);
$address1 = stripslashes($address1);
$town_city = stripslashes($town_city);
$state_county = stripslashes($state_county);
$zip_postcode = stripslashes($zip_postcode);
$security_question = stripslashes($security_question);
$security_answer = stripslashes($security_answer);
$username = stripslashes($username);
$password = stripslashes($password);
$confirm_password = stripslashes($confirm_password);
/* 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(!$address1){
echo "Address 1 is a required field. Please enter it below.<br />";
}
if(!$town_city){
echo "Town/City is a required field. Please enter it below.<br />";
}
if(!$state_county){
echo "State/County is a required field. Please enter it below.<br />";
}
if(!$zip_postcode){
echo "Zip/Postcode is a required field. Please enter it below.<br />";
}
if(!$security_question){
echo "Security Question is a required field. Please enter it below.<br />";
}
if(!$security_answer){
echo "Security Answer is a required field. Please enter it below.<br />";
}
if(!$password){
echo "Password is a required field. Please enter it below.<br />";
}
include 'join_form.html'; // 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 used 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 used by another member in our database. Please choose a different Username!<br />";
unset($username);
}
include 'join_form.html'; // 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! */
/* Random Password generator.
http://www.phpfreaks.com/quickcode/Random_Password_Generator/56.php
We'll generate a random password for the
user and encrypt it, email it and then enter it into the db.
*/
// Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, address1, town_city, state_county, zip_postcode, security_question, security_answer, signup_date)
VALUES('$first_name', '$last_name', '$email_address', '$username', 'md5($password)', '$address1', '$town_city', '$state_county', '$zip_postcode', '$security_question', '$security_answer', now())") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
-
When you fill everything in on the form, which exact echo error does it show you? What does it say is missing?
-
-
Try changing every if (!$something) to
PHP Code:
if (!isset($someting))
-
ok now I get "You did not submit the following required information!" either way. everything filled in and not filled in. that's all it says
-
I took out the ! in that and I'm back at square 1 so I'll put it back in. at least im getting less messages