Code: Select all
<?php
session_start();
include("database.php");
include("signup.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'];
$conn = mysql_connect("ip", "db", "password") or die(mysql_error());
mysql_select_db('db', $conn) or die(mysql_error());
if(isset($username) && isset($password) && isset($password1) && ($answer) && ($answer1)){
if(strlen($password) < 6 || strlen($username) > 64){
echo "Password is either too short or too long\n";
}else {
if($password != $password1){
echo "Password do not match\n";
}else {
if($answer != $answer1){
echo "Password do not match\n";
}else {
$sql = "SELECT * FORM 'users' WHERE 'username' = '$username'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res)){
echo"this username already exists";
}else {
$sql ="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')";
$res = mysql_query($sql) or die(mysql_error());
echo "Your Information has been successfully added to the database.";
}
}
}
}
}
?>