Advertisement
vdp

Untitled

vdp
Jul 31st, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.52 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include("../includes/db.php");
  4. include("../functions/functions.php");
  5. include("../includes/header.php");
  6. ?>
  7.  
  8.  
  9.     <section>
  10.         <div class="container">
  11.             <div class="row">
  12.                 <?php include("../includes/nav.php");?>
  13.  
  14.                 <div class="col-sm-9 padding-right">
  15.                 <div class="features_items"  id="products_box"><!--features_items start-->
  16.                         <h2 class="title text-center">Create an account</h2>
  17.                 <form class="form-group" action="customer_register.php" method="post" enctype="multipart/form-data"/>
  18.  
  19.                 <table width ="750" align="center">
  20.  
  21.                         <tr>
  22.                             <td align="right"><b>Customer Name: </b> </td>
  23.                             <td> <div class="col-xs-8"><input class="form-control" type="text" name="customer_name" required />  </div></td>
  24.                         </tr>
  25.  
  26.                         <tr>
  27.                             <td align="right"><b>Customer Email: </b> </td>
  28.                             <td> <div class="col-xs-8"><input class="form-control" type="text" name="customer_email" required /> </div> </td>
  29.                         </tr>
  30.  
  31.                         <tr>
  32.                             <td align="right"><b>Customer Password: </b> </td>
  33.                             <td> <div class="col-xs-8"><input class="form-control" type="password" name="customer_pass" required />  </div></td>
  34.                         </tr>
  35.  
  36.                                                  <tr>
  37.                             <td align="right"><b>Confirm Password: </b> </td>
  38.                             <td> <div class="col-xs-8"><input class="form-control" type="password" name="customer_pass_confirm" required />  </div></td>
  39.                         </tr>
  40.  
  41.                         <tr>
  42.                             <td align="right"><b>Customer city: </b> </td>
  43.                             <td> <div class="col-xs-8"><input class="form-control" type="text" name="customer_city" required />  </div></td>
  44.                         </tr>
  45.  
  46.                         <tr>
  47.                             <td align="right"><b>Customer Mobile no: </b> </td>
  48.                             <td> <div class="col-xs-8"><input class="form-control" type="text" name="customer_contact" required />  </div></td>
  49.                         </tr>
  50.  
  51.                         <tr>
  52.                             <td align="right"><b>Customer Address: </b> </td>
  53.                             <td> <div class="col-xs-8"><input class="form-control" type="text" name="customer_address" required />  </div></td>
  54.                         </tr>
  55.  
  56.                         <tr>
  57.                             <td align="right"><b>Customer Image: </b> </td>
  58.                             <td> <div class="col-xs-8"><input class="form-control-file" type="file" name="customer_image" required /> <div></td>
  59.                         </tr>
  60.  
  61.                         <tr align="center">
  62.                             <td colspan="10"> <br><input class="btn btn-success" type="submit" name="register" value="Submit" /> </td>
  63.                         </tr>
  64.                     </form>
  65.  
  66.  
  67.                     </div><!--features_items Ends-->
  68.  
  69.  
  70.                     </div><!--/category-tab-->
  71.  
  72.  
  73.  
  74.                 </div>
  75.             </div>
  76.         </div>
  77.     </section>
  78. </body>
  79. </html>
  80.  
  81. <?php
  82.  
  83.     if(isset($_POST['register']))
  84.     {
  85.  
  86.  
  87.  
  88.  
  89.         $customer_pass = $_POST['customer_pass'];
  90.                 $customer_pass_confirm = $_POST['customer_pass_confirm'];
  91.  
  92.     if($customer_pass==$customer_pass_confirm)
  93.    {
  94.  
  95.     $customer_name = $_POST['customer_name'];
  96.         $customer_email = $_POST['customer_email'];
  97.         $customer_country = "Indonesia";
  98.         $customer_city = $_POST['customer_city'];
  99.         $customer_contact = $_POST['customer_contact'];
  100.         $customer_address= $_POST['customer_address'];
  101.  
  102.         $customer_image = $_FILES['customer_image']['name'];
  103.  
  104.         $customer_image_temp = $_FILES['customer_image']['tmp_name'];
  105.  
  106.         $customer_ip = getRealIpAddress();
  107.  
  108.         $insert_customer = "insert into customers(customer_name,customer_email,customer_pass,customer_country,customer_city,customer_contact,customer_address,customer_image,customer_ip)
  109.         values ('$customer_name','$customer_email','$customer_pass','$customer_country','$customer_city','$customer_contact','$customer_address','$customer_image','$customer_ip')";
  110.  
  111.         $run_customer = mysqli_query($con,$insert_customer);
  112.         //uploading a customer photo
  113.         move_uploaded_file($customer_image_temp, "customer/customer_photos/$customer_image");
  114.  
  115.         //checking if this user have anything in the cart if yes we will redirect to payment page
  116.         $sel_cart = "select * from cart where ip_add='$customer_ip'";
  117.  
  118.         $run_cart = mysqli_query($con,$sel_cart);
  119.         $check_cart = mysqli_num_rows($run_cart);
  120.  
  121.         if($check_cart>0)
  122.         {
  123.             //create a session
  124.             $_SESSION['customer_email'] = $customer_email;
  125.             echo "<script>alert('Account has been created') </script>";
  126.             echo "<script>window.open('checkout.php','_self')</script>";
  127.         }
  128.         else
  129.         {
  130.             $_SESSION['customer_email'] = $customer_email;
  131.             echo "<script>alert('Account has been created') </script>";
  132.             echo "<script>window.open('../index.php','_self')</script>";
  133.  
  134.         }
  135.     }//end of password checking
  136. else
  137. {
  138. echo "<script>alert('Password did not match') </script>";
  139. }
  140.    }
  141.  
  142.  
  143. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement