popcheese9

forgot.php

Nov 2nd, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3.     session_start();
  4.    
  5.     if(isset($_SESSION['user'])!="")
  6.     {
  7.         header("Location: home.php");
  8.     }
  9.    
  10.     include_once 'dbconnect.php';
  11.    
  12.     if(isset($_POST['submit'])){
  13.         $email = $_POST['email'];
  14.        
  15.         $query      = "SELECT user_email FROM users WHERE user_email='$email'";
  16.         $result     = mysql_query($query);
  17.        
  18.         $count      = mysql_num_rows($result); // if email not found then register
  19.        
  20.         if($upass == $confPass){
  21.             if($count == 1){
  22.                 ?>
  23.                 <script>alert('Success! Check your email for the link to reset your password.');</script>
  24.                 <?php
  25.                 $success = true;
  26.                        
  27.                 $to         = $email;
  28.                 $from       = 'noreply@failtastic.org';
  29.                 $subject    = 'Signup | Verifictation';
  30.                 $message    = '
  31.                
  32.                 You are getting this email because you have forgotten your password, please click the link below to reset your password.
  33.                
  34.                 -----------------------------
  35.                 Username: '.$user_name.'
  36.                 -----------------------------
  37.                  
  38.                 Please click this link to activate your account:
  39.                 http://www.failtastic.org/Login/verify.php?email='.$email.'&hash='.$hash.'
  40.                
  41.                 Alternate link if that does not work:
  42.                 http://www.failtastic.fragcube.net/Login/verify.php?email='.$email.'&hash='.$hash.'
  43.                
  44.                 ';
  45.                 $headers = 'noreply@failtastic.org' . "\r\n";
  46.                 mail($to, $subject, $message, $headers, $from);
  47.                 header("Location: index.php");
  48.             }else{
  49.                 ?>
  50.                 <script>alert('Email does not exist!');</script>
  51.                 <?php
  52.             }
  53.         }
  54.     }
  55. ?>
  56. <html>
  57.     <head>
  58.         <link rel="stylesheet" type="text/css" href="forgot.css"/>
  59.     </head>
  60.     <body>
  61.         <h1>Forgot Your Password</h1>
  62.         <form method="post">
  63.             <table>
  64.                 <tr>
  65.                     <td class="table">Email:<input type="email" name="email" placeholder="Email" required/></td>
  66.                 </tr>
  67.                 <tr>
  68.                     <td/>
  69.                 </tr>
  70.                 <tr>
  71.                     <td class="table"><button type="submit" name="submit">Send Email</button></td>
  72.                 </tr>
  73.             </table>
  74.         </form>
  75.     </body>
  76. </html>
Add Comment
Please, Sign In to add comment