You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							80 lines
						
					
					
						
							3.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							80 lines
						
					
					
						
							3.0 KiB
						
					
					
				| <?php | |
|   include_once './api/send_mail.php'; | |
|   @include('components/breadcrumb/breadcrumb.php'); | |
|   setlocale(LC_MONETARY, 'it_IT.UTF-8'); | |
|  | |
|   if(isset($_POST['reset_usr'])) { | |
|  | |
|     $query = "SELECT * FROM `users` WHERE email = '".trim($_POST['reset_usr'])."'"; | |
|     $q = mysqli_query($conn, $query); | |
|     if(mysqli_affected_rows($conn)) { | |
|       $new_password = base_convert(date('Y-m-d H:i:s'), 10, 36).rand(1,99)."+"; | |
|       $user = mysqli_fetch_array($q); | |
|  | |
|       $query = "UPDATE `users` SET `password` = '".md5($new_password)."' WHERE id = '".$user['id']."'"; | |
|       $q = mysqli_query($conn, $query); | |
|  | |
|       $toEmail = $user['email']; | |
|       $toName = $user['first_name']." ".$user['last_name']; | |
|       $subject = 'Iolovolio - Reimposta password'; | |
|       $body = emailHeader(); | |
|  | |
|       $body .= "<tr><td colspan=\"4\" style=\"padding: 10px 20px\">Ciao ".$user['first_name'].",<br>". | |
|                 "ricevi questa mail perchè hai richiesto il reset della tua password su Iolovolio, di seguito troverai la tua nuova password temporanea, ti consigliamo di modificarla al primo accesso:<br><br>". | |
|                 "Username: ".$user['email']."<br>". | |
|                 "Nuova password: ".$new_password."<br>". | |
|                 "</td></tr>"; | |
|  | |
|       $body .= "<tr><td colspan=\"4\" style=\"padding: 10px 20px\">Grazie,<br>Servizio Clienti Iolovolio<br><br></td></tr>"; | |
|       $body .= emailFooter(); | |
|  | |
|  | |
|       $sent = sendEmail($toEmail, $toName, $subject, $body, 'noreply'); | |
|       if($sent === true) { | |
|         $message = "Password reimpostata correttamente!<br> | |
|                     Ti abbiamo inviato la nuova password provvisoria all'indirizzo ".trim($_POST['reset_usr']); | |
|       } else { | |
|         $message = "Erore invio mail!<br> | |
|                     Contatta l'assistenza"; | |
|       } | |
|  | |
|     } else { | |
|       $message = "ERRORE: L'indirizzo email inserito non è presente nel database!<br>Controlla l'indirizzo inserito e riprova."; | |
|     } | |
|   } | |
|  | |
| ?> | |
| 
 | |
| <div class="component-passwordRecovery"> | |
|   <div class="container"> | |
|     <div class="row"> | |
| 
 | |
|       <?php | |
|         if($message) { | |
|           echo "<div class=\"message col-12\">$message</div>"; | |
|         } | |
|       ?> | |
| 
 | |
|       <div class="content col-12"> | |
|         <div class="row"> | |
|           <div class="col-12 col-md-6 mb-5"> | |
|             <span class="title">Hai dimenticato la password?</span> | |
|             <span class="subtitle">Inserisci l'indirizzo email-con il quale ti sei registrato</span> | |
|             <form class="reset-form <?= $no_user ? 'error' : '';?>" action="/recupera-password" method="POST"> | |
|               <div class="row"> | |
|                 <div class="col-12"> | |
|                   <span class="label">E-mail</span> | |
|                   <input type="email" name="reset_usr" class="input input-text"> | |
|                 </div> | |
|                 <div class="col-12 mt-4"> | |
|                   <button class="button button-brown button-big mr-auto">Reimposta password</button> | |
|                 </div> | |
|               </div> | |
|             </form> | |
|           </div> | |
|         </div> | |
|       </div> | |
|     </div> | |
|   </div> | |
| </div> | |
| 
 |