Advertisement
vdp

Untitled

vdp
Jul 31st, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.12 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Customer Login</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <?php
  11.     @session_start(); //no error if it's not initialised
  12.     include("../includes/db.php");
  13.     require("../functions/sendmail.php");
  14.     //include("functions/functions.php");
  15. ?>
  16.     <div>
  17.  
  18.  
  19.     <form action="checkout.php" method="post">
  20.  
  21.         <table width="600" align="center">
  22.             <tr>
  23.                 <td align="right"><b><label for="customer-email">Your Email : &nbsp;</label></b></td>
  24.                 <td align="left"><input class="form-control" type="text" name="customer_email" value=""/><br/></td>
  25.             </tr>
  26.             <tr>
  27.                 <td align="right"><b><label for="customer-pass">Your Password : &nbsp;</label></b></td>
  28.                 <td align="left"><input class="form-control" type="password" name="customer_pass" value=""/><br/></td>
  29.             </tr>
  30.             <tr>
  31.             <tr>
  32.                 <td colspan="5"><a href="checkout.php?forgot_pass">Forgot Password</a></td>
  33.             </tr>
  34.                 <td colspan="5"><input type="submit" class="btn btn-success" name="customer_login" value="Login"/></td>
  35.             </tr>
  36.  
  37.         </table>
  38.      </form>
  39.  
  40.  
  41.      <?php
  42.  
  43.         if(isset($_GET['forgot_pass']))
  44.         {
  45.             echo "
  46.             <br><br>
  47.  
  48.             <div align='center'>
  49.             <b> Enter your email please </b>
  50.  
  51.             <form action='' method='post'>
  52.  
  53.                 <input type='text' class='form-control' name='c_email' required placeholder='Enter your email'/>
  54.                 <br>
  55.                 <input type='submit' class='btn btn-danger' name='forgot_pass' value='Send me password' />
  56.  
  57.             </form>
  58.             </div>
  59.  
  60.             ";
  61.  
  62.             //if forgot button is clicked
  63.             if(isset($_POST['forgot_pass']))
  64.             {
  65.                 //get user email
  66.                 //email textbox/forgot pass
  67.                 $c_email=$_POST['c_email'];
  68.                 $sel_c="select * from customers where customer_email='$c_email'";
  69.                 $run_c=mysqli_query($con,$sel_c);
  70.  
  71.                 //check if email was found in the database
  72.                 $check_c=mysqli_num_rows($run_c);
  73.  
  74.                 $row_c=mysqli_fetch_array($run_c);
  75.                 $c_name=$row_c['customer_name'];
  76.                 $c_pass=$row_c['customer_pass'];
  77.  
  78.                 if($check_c==0)
  79.                 {
  80.                     echo "<script>alert('Email was not found in our database!!') </script>";
  81.                     exit();
  82.                 }
  83.                 else
  84.                 {
  85.                     sendMail($c_email,"Forgot Password","<p>Your current password is </p><p><h2>".$c_pass."</h2></p>",$c_name);
  86.                     echo "<script>alert('Email sent. Check your email') </script>";
  87.                     echo "<script>window.open('checkout.php','_self')</script>";
  88.                 }
  89.  
  90.             }
  91.         }
  92.  
  93.  
  94.      ?>
  95.  
  96.  
  97.  
  98.      <h4 align="center"><a href="customer_register.php">New Customer Registers Here</a></h4>
  99.  
  100. </div>
  101. <?php
  102. //fires out  when user clicks login
  103.  
  104. if(isset($_POST['customer_login']))
  105. {
  106.     //checking if the user/customer login credentials exist in the database.
  107.     $customer_email = $_POST['customer_email'];
  108.     $customer_pass = $_POST['customer_pass'];
  109.  
  110.     $select_customer = "SELECT * FROM customers where customer_email='$customer_email' AND customer_pass='$customer_pass'";
  111.     $run_customer = mysqli_query($con,$select_customer);
  112.  
  113.     $check_customer=mysqli_num_rows($run_customer);
  114.     $get_ip = getRealIpAddress(); //there is an include on the top
  115.     //if there are any items that needs to be checked out we will direct them to checkout page when the user is logged in
  116.     $sel_cart = "select * from cart where ip_add='$get_ip'";
  117.  
  118.     $run_cart = mysqli_query($con,$sel_cart);
  119.     $check_cart = mysqli_num_rows($run_cart);
  120.  
  121.     if($check_customer==0)
  122.     {
  123.         echo "<script>alert('Password/email address is incorrect') </script>";
  124.         exit(); //returning
  125.     }
  126.     if($check_customer==1 AND $check_cart==0)
  127.     {
  128.  
  129.         $_SESSION['customer_email']=$customer_email;
  130.         //redirect
  131.         echo "<script>window.open('my_account.php','_self')</script>";
  132.     }
  133.     else
  134.     {
  135.         $_SESSION['customer_email']=$customer_email;
  136.         //echo "<script>window.open('payment_options.php','_self')</script>";
  137.         echo "<script>alert('You have successfully logged in!!')</script>";
  138.         echo "<script>window.open('checkout.php','_self')</script>";
  139.         //include("payment_options.php");
  140.     }
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. }
  148. ?>
  149. </body>
  150. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement