Advertisement
humanware

day_13_signup_process.php

Sep 19th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['signup_submit'])) {
  4. include_once '../includes/dbconnection.php';
  5.  
  6. $name = mysqli_real_escape_string($conn, $_POST['name']);
  7. $email = mysqli_real_escape_string($conn, $_POST['email']);
  8. $username = mysqli_real_escape_string($conn, $_POST['username']);
  9. $password = mysqli_real_escape_string($conn, $_POST['password']);
  10.  
  11. if(empty($name) || empty($email) || empty($username) || empty($password)) {
  12. header("Location: signup.php?error=empty_fields");
  13. exit;
  14. } else {
  15. // Check if input characters are valid
  16. if(!preg_match("/^[a-zA-Z]*$/", $name) || !preg_match("/^[a-zA-Z]*$/", $username)) {
  17. header("Location: signup.php?error=char_error");
  18. exit;
  19. } else {
  20. if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  21. header("Location: signup.php?error=email_error");
  22. exit;
  23. } else {
  24. header("Location: signup.php?error=success");
  25. exit;
  26. }
  27. }
  28. }
  29.  
  30.  
  31. } else {
  32. header('Location: signup.php');
  33. exit;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement