Some of the problems are:
1) The code doesn't check if answer & answer1 are not the same
2) The my page redirect produces an error
3) The code doesn't seem to break properly
ANY advice or suggestions are welcome!! Thanks
Code: Select all
<?php
session_start();
include("database.php");
$username = $_POST['username'];
$password = $_POST['password'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$password2 = $_POST['password2'];
$street = $_POST['street'];
$apt = $_POST['apt'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$birthday_month = $_POST['birthday_month'];
$birthday_day = $_POST['birthday_day'];
$birthday_year = $_POST['birthday_year'];
$gender = $_POST['gender'];
$question = $_POST['question'];
$answer = $_POST['answer'];
$answer1 = $_POST['answer1'];
//end validation
$loginErr=0;
if(isset($_POST['Submit']))
{
if($password != $password2){
$loginErr=1;
}
elseif(strlen($_POST['password']) < 6){
$loginErr=2;
}
elseif($answer != $answer1){
$loginErr=3;
}
else
{
switch($loginErr)
{
case 1:
echo"Passwords do not match! <meta http-equiv="Refresh"content="2;url=signup.php"/>"; //redirect
break;
case 2:
echo"Passwords must contain at least 6 characters!"; //redirect
break;
case 3:
echo"Your answer does not match. Please re-answer."; //redirect
break;
//etc...
}
}
if($loginErr==0){
$query="INSERT INTO users (username, password,firstname, lastname, email, password2, street, apt, city, state, zip, phone, birthday_month, birthday_day, birthday_year, gender, question, answer, answer1) VALUES ('$username','$password','$firstname','$lastname','$email','$password2','$street','$apt','$city','$state','$zip','$phone','$birthday_month','$birthday_day', '$birthday_year','$gender','$question','$answer','$answer1')";
}
}
$connect = mysql_connect('ip', 'db, 'password') or die("Unable to Connect to Database<br>".mysql_error());
mysql_select_db('askslicky') or die("Unable to Select Database<br>".mysql_error());
mysql_close($connect) or die("Unable to Close Database<br>".mysql_error());
echo " Your Information has been successfully added to the database. Thank you for your registration to ";
?>