Advertisement
melody45

recover

Mar 25th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1.  
  2. <?php
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "bmisystem";
  7.  
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9. // Check connection
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13.  
  14. $email = $_POST['email'];
  15. $sql = "SELECT * FROM users WHERE u_email='$email'";
  16. $result = mysqli_query($conn, $sql);
  17. if (mysqli_num_rows($result) > 0) {
  18. while($row = mysqli_fetch_assoc($result)) {
  19. $to = $row['u_email'];
  20. $pass = $row['u_pass'];
  21. $name = $row['first_name'];
  22. $msg = '
  23. Hi '.$name.' <br>
  24. Your Login Password is '.$pass.' <br>
  25. Thank you
  26. ';
  27. $subject = "Password Recovery Notification";
  28. $from = "no-reply@progsofts.com";
  29. }
  30.  
  31. if ($to = $email){
  32.  
  33. $send = mail($to, $subject, $msg, $from);
  34. }
  35. if($send){
  36.  
  37. echo "<script>alert('Password has been sent to your Email.. Thanks');</script>";
  38. }
  39. }else{
  40. echo "<script>alert('EMail ID you provided is not assigned to any account. Try again with a correct email');</script>";
  41. }
  42.  
  43. mysqli_close($conn);
  44.  
  45. ?>
  46.  
  47. <table border="0" style="width:400px;margin:0 auto;border:2px solid #F25822;
  48. border-radius:5px;padding-top:15px;padding-left:5px;padding-bottom:15px;padding-right:5px;box-shadow:0px 0px 5px 5px grey;margin-top:40px;margin-bottom:30px;">
  49. <tr>
  50. <td> Please Provide your Registered Email to recover </td></tr>
  51. <tr><td><hr><td></tr>
  52. <tr>
  53. <form name="recover" method="post" action="recover.php">
  54. <td><input type="email" size="40" name="email"></td></tr>
  55. <tr><td align="center"><input type="submit" value="Send Password" class="button" required style="width:200px;"></td></tr>
  56. </form>
  57.  
  58. </table>
  59.  
  60.  
  61. </div>
  62.  
  63.  
  64.  
  65. <?php
  66. include 'footer.php';
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement