getConnection(); } catch (Exception $e) { logError('Database connection failed in signup.php: ' . $e->getMessage()); $errors[] = 'System error. Please try again later.'; } if (empty($errors)) { // Get and sanitize form data $email = isset($_POST['email']) ? sanitize($_POST['email']) : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $gender = isset($_POST['gender']) ? sanitize($_POST['gender']) : ''; $dateOfBirth = isset($_POST['date_of_birth']) ? sanitize($_POST['date_of_birth']) : ''; $postcode = isset($_POST['postcode']) ? sanitize($_POST['postcode']) : ''; $privacyAccepted = isset($_POST['privacy_policy']) ? true : false; // Store form data for repopulating form on error $form_data = [ 'email' => $email, 'gender' => $gender, 'date_of_birth' => $dateOfBirth, 'postcode' => $postcode ]; // Validation if (empty($email)) { $errors[] = 'Email is required.'; } if (empty($password)) { $errors[] = 'Password is required.'; } if (empty($gender)) { $errors[] = 'Gender is required.'; } if (empty($dateOfBirth)) { $errors[] = 'Date of birth is required.'; } if (empty($postcode)) { $errors[] = 'Postcode is required.'; } if (!$privacyAccepted) { $errors[] = 'You must agree to the Privacy Policy and Terms & Conditions.'; } // Validate email format if (!empty($email) && !validateEmail($email)) { $errors[] = 'Please provide a valid email address.'; } // Validate password strength if (!empty($password) && !validatePassword($password)) { $errors[] = 'Password must be at least 8 characters long.'; } // Validate gender if (!empty($gender) && !in_array($gender, ['Male', 'Female'])) { $errors[] = 'Please select a valid gender.'; } // Validate date of birth if (!empty($dateOfBirth) && !validateDateOfBirth($dateOfBirth)) { $errors[] = 'You must be at least 18 years old to register.'; } // Validate postcode if (!empty($postcode) && !validatePostcode($postcode)) { $errors[] = 'Please provide a valid 6-digit postal code.'; } // If no validation errors, proceed with registration if (empty($errors)) { try { // Check if email already exists $stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->rowCount() > 0) { $errors[] = 'An account with this email address already exists. Please try logging in or use a different email.'; } else { // Hash the password $hashedPassword = hashPassword($password); // Start transaction $pdo->beginTransaction(); // Insert new user $stmt = $pdo->prepare(" INSERT INTO users (email, password, gender, date_of_birth, postcode, email_verified, status, created_at) VALUES (?, ?, ?, ?, ?, 0, 'inactive', NOW()) "); $stmt->execute([$email, $hashedPassword, $gender, $dateOfBirth, $postcode]); $userId = $pdo->lastInsertId(); // Generate verification token $verificationToken = generateSecureToken(); $expiresAt = date('Y-m-d H:i:s', strtotime('+' . TOKEN_EXPIRY_HOURS . ' hours')); // Insert verification token $stmt = $pdo->prepare(" INSERT INTO email_verifications (user_id, token, expires_at, created_at) VALUES (?, ?, ?, NOW()) "); $stmt->execute([$userId, $verificationToken, $expiresAt]); // Commit transaction $pdo->commit(); // Send verification email $emailHandler = new EmailHandler(); $emailSent = $emailHandler->sendVerificationEmail($email, $verificationToken); if ($emailSent) { logError('User registered successfully', [ 'user_id' => $userId, 'email' => $email, 'verification_token_sent' => true ]); $success_message = 'Registration successful! We\'ve sent a verification link to your email address. Please check your inbox and click the link to activate your account.'; $form_data = []; // Clear form data on success } else { // Registration was successful but email failed logError('User registered but email verification failed', [ 'user_id' => $userId, 'email' => $email ]); $success_message = 'Registration successful! However, we encountered an issue sending the verification email. Please contact support at support@relevantreflex.com to activate your account.'; $form_data = []; } } } catch (PDOException $e) { // Rollback transaction on error if ($pdo->inTransaction()) { $pdo->rollback(); } logError('Database error during registration', [ 'error' => $e->getMessage(), 'email' => $email ]); $errors[] = 'Registration failed due to a system error. Please try again later.'; } catch (Exception $e) { // Rollback transaction on error if ($pdo->inTransaction()) { $pdo->rollback(); } logError('General error during registration', [ 'error' => $e->getMessage(), 'email' => $email ]); $errors[] = 'An unexpected error occurred. Please try again later.'; } } } } ?> Sign Up - Relevant Reflex Paid Online Surveys India

Register as a Survey Taker for FREE!

Furnish some of your basic information below and start making money online through Paid Surveys.

Minimum 8 characters
We care about your privacy. By sharing your personal data you will be able to get research opportunities targeted to your interests, help to improve products and services and earn rewards for participation
What's Next?

Check your email inbox and click the verification link to activate your account.

Didn't receive the email? Check your spam folder or contact support