Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conn=mysqli_connect("localhost","root","","chocolateshop"); //connect to database
- if (!$conn){
- die('Could not connect: ' . mysqli_connect_errno()); //return error is connect fail
- }
- $error="";
- /*if ($_SERVER["REQUEST_METHOD"] == "POST"){
- if(empty($_POST['userBox'])){
- $usererror="Username is required";
- }else {
- $username = $_POST['userBox'];
- if (!preg_match("/^[A-Za-z0-9_]{9,21}$/", $username)){
- $usererror="Username can only contain numbers or letters or underscore from 9 to 21 characters";
- }
- }
- if(empty($_POST['passBox'])){
- $passerror="Password cannot be empty";
- }else {
- $password = $_POST['passBox'];
- if (!preg_match("$\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])(?=\S*[\W])\S*$", $password)){
- $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";
- }
- }
- }
- */
- //('$userName', '$firstName', '$lastName', '$dob', '$gender, '$contact', '$email', '$address','$zip','$password');");
- if(isset($_POST["insert"])){
- //$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');") ;
- //$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(?,?,?,?,?,?,?,?,?,?)") ;
- $firstName=$_POST["firstName"];
- $lastName=$_POST["lastName"];
- $address=$_POST["address"];
- $zip=$_POST["zip"];
- $gender=$_POST['gender'];
- $contact=$_POST["contact"];
- $email=$_POST["email"];
- $dob=$_POST["dob"];
- $userName=$_POST["userName"];
- $password=$_POST["password"];
- $query=mysqli_query( 'Select * from customer_informaiton where customer_login='" .$userName."'',$conn);
- $numrows=mysqli_num_rows($query);
- if($numrows==0 || !$numrows)
- {
- $sql="insert into customer_information(customer_login,password) values ('$userName','$password')";
- }
- $result=mysql_query($conn,$sql);
- //$query->bind_param("ssssssssss",$userName, $firstName, $lastName, $dob, $gender, $contact, $email, $address, $zip, $password);
- if($result)
- {
- echo "<center>Record Inserted!</center><br>";
- }
- else{
- echo "Error executing query.";
- }
- $conn->close();
- }
- //}
- //input check
- //if ($_SERVER["REQUEST_METHOD"] == "POST"){
- //$count=0;
- //}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement