$value) { if(empty($_POST[$key])) { $error_message = "All Fields are required"; break; } } /* Password Matching Validation */ if($_POST['password'] != $_POST['confirm_password']){ $error_message = 'Passwords should be same
'; } /* Email Validation */ if(!isset($error_message)) { if (!filter_var($_POST["userEmail"], FILTER_VALIDATE_EMAIL)) { $error_message = "Invalid Email Address"; } } /* Validation to check if gender is selected */ if(!isset($error_message)) { if(!isset($_POST["gender"])) { $error_message = " All Fields are required"; } } /* Validation to check if Terms and Conditions are accepted */ if(!isset($error_message)) { if(!isset($_POST["terms"])) { $error_message = "Accept Terms and Conditions to Register"; } } if(!isset($error_message)) { require_once("dbcontroller.php"); $db_handle = new DBController(); $query = "INSERT INTO registered_users (user_name, first_name, last_name, password, email, gender) VALUES ('" . $_POST["userName"] . "', '" . $_POST["firstName"] . "', '" . $_POST["lastName"] . "', '" . md5($_POST["password"]) . "', '" . $_POST["userEmail"] . "', '" . $_POST["gender"] . "')"; $result = $db_handle->insertQuery($query); if(!empty($result)) { $error_message = ""; $success_message = "You have registered successfully!"; unset($_POST); } else { $error_message = "Problem in registration. Try Again!"; } } } ?> PHP User Registration Form
User Name
First Name
Last Name
Password
Confirm Password
Email
Gender checked> Male checked> Female
I accept Terms and Conditions