Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "db.php";
- // define variables and set to empty values
- $nameErr = $emailErr = $genderErr = $passwordErr = $cpasswordErr = "";
- $cpassword = "";
- $cust_email = $cust_username = $cust_password = $cust_fullname = $cust_country = $cust_dob = $cust_gender = $cust_phone ="";
- if(isset($_POST["btnsignup"]))
- {
- //Username Validation
- $cust_username = $_POST["txtcust_username"];
- // check if name only contains letters and whitespace
- if (!preg_match("/^[a-zA-Z ]*$/",$cust_username)) {
- $nameErr = "Only letters and white space allowed";
- }
- //Email Validation
- $cust_email = $_POST["txtcust_email"];
- // check if e-mail address is well-formed
- if (!filter_var($cust_email, FILTER_VALIDATE_EMAIL)) {
- $emailErr = "Invalid email format";
- }
- //Password Validation
- if(!empty($_POST["txtcust_password"]) && ($_POST["txtcust_password"] == $_POST["txtcust_cpassword"])) {
- $cust_password = $_POST["txtcust_password"];
- $cpassword = $_POST["txtcust_cpassword"];
- if (strlen($_POST["txtcust_password"]) <= '6') {
- $passwordErr = "Your Password Must Contain At Least 6 Characters!";
- }
- elseif(!preg_match("#[0-9]+#",$cust_password)) {
- $passwordErr = "Your Password Must Contain At Least 1 Number!";
- }
- elseif(!preg_match("#[A-Z]+#",$cust_password)) {
- $passwordErr = "Your Password Must Contain At Least 1 Capital Letter!";
- }
- elseif(!preg_match("#[a-z]+#",$cust_password)) {
- $passwordErr = "Your Password Must Contain At Least 1 Lowercase Letter!";
- }
- }
- elseif(!empty($_POST["txtcust_password"])) {
- $cpasswordErr = "Please Check You've Entered Or Confirmed Your Password!";
- }
- if ($cust_username && $cust_email && $cust_password )
- {
- //Insert Into Table
- $insert = "INSERT INTO customer (cust_email,cust_username,cust_password,cust_fullname,cust_country,cust_dob,cust_gender,cust_phone)
- VALUES ('$cust_email','$cust_username','$cust_password','$cust_fullname','$cust_country','$cust_dob','$cust_gender','$cust_phone')";
- $run = mysqli_query($conn,$insert);
- if($run)
- {
- setcookie("Name",$cust_username);
- header("Location: home.php");
- }
- }
- else {
- echo "User has not been Add";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement