register.php (2262B)
1 <?php 2 ini_set('display_errors', 'On'); 3 error_reporting(E_ALL | E_STRICT); 4 5 if (isset($_POST['submit'])) { 6 include_once '../config.php'; 7 $email = mysqli_real_escape_string($connect, $_POST['email']); 8 $username = mysqli_real_escape_string($connect, $_POST['username']); 9 $password = mysqli_real_escape_string($connect, $_POST['password']); 10 11 if (empty($email) || empty($username) || empty($password)) { 12 header("Location: ../signup.php?signup=empty"); 13 exit(); 14 } else { 15 if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { 16 header("Location: ../signup.php?signup=email"); 17 exit(); 18 } else { 19 $sql = "SELECT * FROM user WHERE username = '$username'"; 20 $result = mysqli_query($connect, $sql); 21 $check = mysqli_num_rows($result); 22 23 if ($check > 0) { 24 header("Location: ../signup.php?signup=email"); 25 exit(); 26 } else { 27 $hashPass = password_hash($password, PASSWORD_DEFAULT); 28 $date = date("Y-m-d H:i:s"); 29 $sql = "INSERT INTO user (email, username, password, 30 registration_date) 31 VALUES ('$email', '$username', '$hashPass', '$date');"; 32 33 mysqli_query($connect, $sql); 34 /* 35 $to = $email; // Send email to our user 36 $subject = 'Signup | Verification'; // Give the email a subject 37 $message = ' 38 39 Thanks for signing up! 40 Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below. 41 42 ------------------------ 43 Username: '.$username.' 44 Password: '.$password.' 45 ------------------------ 46 47 Please click this link to activate your account: 48 http://www.surveyseahorse.com/verify.php?email='.$email.'&hash='.$hash.' 49 50 '; 51 52 $headers = 'From:noreply@surveyseahorse.com' . "\r\n"; // Set from headers 53 mail($to, $subject, $message, $headers); // Send our email 54 */ 55 56 // header("Location: ../signup.php?signup=success"); 57 header("Location: ../index.php"); 58 exit(); 59 } 60 } 61 } 62 63 } else { 64 header("Location: ../profile.php"); 65 exit(); 66 } 67 ?>