-
+ if(isset($_POST['email'], $_POST['name'], $_POST['password'], $_POST['city'], $_POST['mob_no'], $_POST['subscribe'])) {
+ $email = $_POST['email'];
+ $name = $_POST['name'];
+ $password = $_POST['password'];
+ $city = $_POST['city'];
+ $mob_no = $_POST['mob_no'];
+ $profile = $_POST['relation'];
+ $gender = $_POST['sex'];
+ $religion = $_POST['religion'];
+ $dob = $_POST['dob'];
+ $state = $_POST['state'];
+
+ $errors = array();
+
+ // Validation checks
+ if(empty($email) || empty($name) || empty($password) || empty($city) || empty($mob_no) || empty($profile) ||
+ empty($gender) || empty($religion) || empty($dob) || empty($state)) {
+ $errors[] = 'All fields are required';
+ } else {
+ if(filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
+ $errors[] = 'Email address is not valid';
+ }
+ if(strlen($email) > 255 || strlen($name) > 35 || strlen($city) > 35) {
+ $errors[] = 'One or more fields contain too many characters';
+ }
+ if(user_exists($email)) {
+ $errors[] = 'That email has already been registered';
+ }
+ if (!preg_match("/^[a-zA-Z ]*$/", $name)) {
+ $errors[] = "Only letters and white space allowed in name";
+ }
+ if (!preg_match("/^[a-zA-Z ]*$/", $city)) {
+ $errors[] = "Only letters and white space allowed in city name";
+ }
+ if (!preg_match("/^[0-9 ]*$/", $mob_no)) {
+ $errors[] = "Only numbers allowed in mobile number";
+ }
+ }
-
-
-
+ // Display errors if any
+ if(!empty($errors)) {
+ echo '
';
+ foreach($errors as $error) {
+ echo '- '.$error.'
';
+ }
+ echo '
';
+ } else {
+ // Registration successful
+ $register = user_register($profile, $name, $gender, $dob, $religion, $city, $state, $mob_no, $email, $password);
+ if($register !== 0) {
+ $_SESSION['user_id'] = $register;
+ header('Location: index.php');
+ exit();
+ }
+ }
+ }
+ ?>
+
+
-255 || strlen($email)>35 || strlen($email)>35)
- {
- $errors[]='One or more fields contains too many characters';
- }
- if(user_exists($email)== true)
- {
- $errors[]='That email has already been registered';
- }
- if (!preg_match("/^[a-zA-Z ]*$/",$name))
- {
- $errors[] = "Only letters and white space allowed in name";
- }
- if (!preg_match("/^[a-zA-Z ]*$/",$city))
- {
- $errors[] = "Only letters and white space allowed in city name";
- }
- if (!preg_match("/^[0-9 ]*$/",$mob_no))
- {
- $errors[] = "Only letters and white space allowed in mobile number";
- }
- }
- if(!empty($errors))
- {
- foreach($errors as $error)
- {
- echo $error,'
';
- }
- }
- else
- {
- //echo $profile,$name,$gender,$day,$month,$year,$religion,$city,$state,$mob_no,$email;
- $register = user_register($profile,$name,$gender,$dob,$religion,$city,$state,$mob_no,$email,$password);
- if($register !== 0)
- $_SESSION['user_id'] = $register;
- //echo $_SESSION['user_id'];
- //echo $register;
- header('Location: index.php');
- //exit();
- }
-}
-?>
-
-
-
-
-
-