Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. <?php
  2.  
  3. include "db.php";
  4.  
  5. // define variables and set to empty values
  6. $nameErr = $emailErr = $genderErr = $passwordErr = $cpasswordErr = "";
  7. $cpassword = "";
  8. $cust_email = $cust_username = $cust_password = $cust_fullname = $cust_country = $cust_dob = $cust_gender = $cust_phone ="";
  9.  
  10. if(isset($_POST["btnsignup"]))
  11. {
  12.  
  13.  
  14.  
  15. //Username Validation
  16. $cust_username = $_POST["txtcust_username"];
  17. // check if name only contains letters and whitespace
  18. if (!preg_match("/^[a-zA-Z ]*$/",$cust_username)) {
  19. $nameErr = "Only letters and white space allowed";
  20. }
  21.  
  22.  
  23. //Email Validation
  24. $cust_email = $_POST["txtcust_email"];
  25. // check if e-mail address is well-formed
  26. if (!filter_var($cust_email, FILTER_VALIDATE_EMAIL)) {
  27. $emailErr = "Invalid email format";
  28. }
  29.  
  30.  
  31. //Password Validation
  32. if(!empty($_POST["txtcust_password"]) && ($_POST["txtcust_password"] == $_POST["txtcust_cpassword"])) {
  33. $cust_password = $_POST["txtcust_password"];
  34. $cpassword = $_POST["txtcust_cpassword"];
  35. if (strlen($_POST["txtcust_password"]) <= '6') {
  36. $passwordErr = "Your Password Must Contain At Least 6 Characters!";
  37. }
  38. elseif(!preg_match("#[0-9]+#",$cust_password)) {
  39. $passwordErr = "Your Password Must Contain At Least 1 Number!";
  40. }
  41. elseif(!preg_match("#[A-Z]+#",$cust_password)) {
  42. $passwordErr = "Your Password Must Contain At Least 1 Capital Letter!";
  43. }
  44. elseif(!preg_match("#[a-z]+#",$cust_password)) {
  45. $passwordErr = "Your Password Must Contain At Least 1 Lowercase Letter!";
  46. }
  47.  
  48. }
  49. elseif(!empty($_POST["txtcust_password"])) {
  50. $cpasswordErr = "Please Check You've Entered Or Confirmed Your Password!";
  51. }
  52.  
  53.  
  54.  
  55. if ($cust_username && $cust_email && $cust_password )
  56. {
  57. //Insert Into Table
  58. $insert = "INSERT INTO customer (cust_email,cust_username,cust_password,cust_fullname,cust_country,cust_dob,cust_gender,cust_phone)
  59. VALUES ('$cust_email','$cust_username','$cust_password','$cust_fullname','$cust_country','$cust_dob','$cust_gender','$cust_phone')";
  60.  
  61. $run = mysqli_query($conn,$insert);
  62. if($run)
  63. {
  64. setcookie("Name",$cust_username);
  65. header("Location: home.php");
  66. }
  67.  
  68. }
  69.  
  70. else {
  71. echo "User has not been Add";
  72. }
  73.  
  74. }
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement