Guest User

Untitled

a guest
May 13th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'functions.php';
  4. include 'connect.php';
  5. $action = isset($_GET['action']);
  6. $email = "leeg";
  7.  
  8. switch($action){
  9.     // case 'redirect':
  10.         // header('Location: index.php');
  11.        
  12.        
  13.     case 'sendemail':    
  14.         $user = sanitize($_POST['mail_to']);
  15.        
  16.         $query1="SELECT email FROM \"AutoForum\".gebruikers  WHERE nickname = '".$user."'";
  17.         $email= $db->query($query1);
  18.         echo $email;
  19.         //echo $email[0]['email'];
  20.        
  21.     if(!empty($email)){
  22.     //if(!empty($email[0]['email'])){
  23.         $random_password=md5(uniqid(rand()));
  24.         $new_password=substr($random_password, 0, 8);
  25.        
  26.         $subject="Your forgotten password here";
  27.         $header="from: AutoForum";
  28.         $messages= "Here is your new password for login to our website \r\n.";
  29.         $messages.="Your password is '".$new_password."' \r\n";
  30.         $messages.="Kind regards, \r\n";
  31.         $messages.="Alexander van Boekholdt";
  32.         $messages.="Moderator";
  33.         echo $messages;
  34.        // mail($email,$subject,$messages,$header);
  35.         $pwdtabel = md5($new_password);
  36.         //$query2="update \"AutoForum\".gebruikers set wachtwoord = '".$pwdtabel."' WHERE nickname = '".$user."'";
  37.         //$db->query($query2);
  38.         echo "mail sent";
  39.  
  40.     }
  41.     else{
  42.         echo "mail not sent";
  43.     }
  44.  
  45.    
  46.  
  47.    
  48. }
  49.  
  50. giveHeader('Password Sent - AutoForum');
  51.  
  52.  
  53.  
  54.  
  55. ?>
  56.  
  57. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#606060" height="auto">
  58.     <tr>
  59.         <td width="33%"><strong>Enter your nickname: </strong></td>
  60.         <td width="67%">
  61.             <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=sendemail">
  62.                 <input name="mail_to" type="text" id="mail_to" size="25">
  63.                 <input type="submit" name="Submit" value="Submit">
  64.             </form>
  65.         </td>
  66.        
  67.     </tr>
  68. </table>
  69. <table>
  70.     <tr>
  71.        
  72.     </tr>
  73. </table>
  74. <?php
  75. // <form method="post" action="?><?php //echo $_SERVER['PHP_SELF']; <?php?>?action=redirect">
  76.             // <input type="submit" id="Redirect" value="Back" >
  77.         // </form>
  78. giveFooter();
  79. ?>
Add Comment
Please, Sign In to add comment