Advertisement
Guest User

Untitled

a guest
Feb 4th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. $conn=mysqli_connect("localhost","root","","chocolateshop"); //connect to database
  9. if (!$conn){
  10. die('Could not connect: ' . mysqli_connect_errno()); //return error is connect fail
  11. }
  12.  
  13.  
  14. $error="";
  15.  
  16. /*if ($_SERVER["REQUEST_METHOD"] == "POST"){
  17. if(empty($_POST['userBox'])){
  18. $usererror="Username is required";
  19. }else {
  20. $username = $_POST['userBox'];
  21. if (!preg_match("/^[A-Za-z0-9_]{9,21}$/", $username)){
  22. $usererror="Username can only contain numbers or letters or underscore from 9 to 21 characters";
  23. }
  24. }
  25. if(empty($_POST['passBox'])){
  26. $passerror="Password cannot be empty";
  27. }else {
  28. $password = $_POST['passBox'];
  29. if (!preg_match("$\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])(?=\S*[\W])\S*$", $password)){
  30. $passerror="Password length must be at least 8 and password must contain at least one lowercase letter and at least one uppercase letter and at least one number and at least a special character";
  31. }
  32. }
  33. }
  34. */
  35. //('$userName', '$firstName', '$lastName', '$dob', '$gender, '$contact', '$email', '$address','$zip','$password');");
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. if(isset($_POST["insert"])){
  43.  
  44.  
  45.  
  46.  
  47. //$query=$conn->prepare("insert into customer_information(customer_login, customer_firstname, customer_lastname, customer_DOB, customer_gender, customer_contact, customer_email, customer_address,customer_postalcode,customer_password)values('$userName','$firstName','$lastName','$dob','$gender','$contact','$email','$address','$zip','$password');") ;
  48.  
  49. //$query=$conn->prepare("INSERT INTO customer_information(customer_login, customer_firstname, customer_lastname, customer_DOB, customer_gender, customer_contact, customer_email, customer_address,customer_postalcode,customer_password)values(?,?,?,?,?,?,?,?,?,?)") ;
  50. $firstName=$_POST["firstName"];
  51. $lastName=$_POST["lastName"];
  52. $address=$_POST["address"];
  53. $zip=$_POST["zip"];
  54. $gender=$_POST['gender'];
  55. $contact=$_POST["contact"];
  56. $email=$_POST["email"];
  57. $dob=$_POST["dob"];
  58. $userName=$_POST["userName"];
  59. $password=$_POST["password"];
  60. $query=mysqli_query( 'Select * from customer_informaiton where customer_login='" .$userName."'',$conn);
  61. $numrows=mysqli_num_rows($query);
  62. if($numrows==0 || !$numrows)
  63. {
  64. $sql="insert into customer_information(customer_login,password) values ('$userName','$password')";
  65. }
  66.  
  67. $result=mysql_query($conn,$sql);
  68.  
  69. //$query->bind_param("ssssssssss",$userName, $firstName, $lastName, $dob, $gender, $contact, $email, $address, $zip, $password);
  70.  
  71.  
  72. if($result)
  73. {
  74. echo "<center>Record Inserted!</center><br>";
  75. }
  76. else{
  77. echo "Error executing query.";
  78. }
  79.  
  80.  
  81. $conn->close();
  82. }
  83.  
  84.  
  85.  
  86. //}
  87. //input check
  88. //if ($_SERVER["REQUEST_METHOD"] == "POST"){
  89.  
  90. //$count=0;
  91.  
  92. //}
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement