Your IP : 216.73.216.162


Current Path : /home/xbodynamge/namtation/reservation/
Upload File :
Current File : /home/xbodynamge/namtation/reservation/password.php

<?php
include_once('./inc/init.inc.php');


function new_password($nb_car, $chaine = 'azertyupqsdfghjkmwxcvbn23456789')
{
    $nb_lettres = strlen($chaine) - 1;
    $generation = '';
    for($i=0; $i < $nb_car; $i++)
    {
        $pos = mt_rand(0, $nb_lettres);
        $car = $chaine[$pos];
        $generation .= $car;
    }
    return $generation;
}



$sql = "select count(*) as existe from reservation".$DB_prefixtable."client where email='".$_POST['email']."' and webaccess=1";
$req = mysqli_query($db, $sql) or die('Erreur SQL !'.mysqli_error()); 
$client = mysqli_fetch_assoc($req);

if ($client['existe']==0) {
  header('Location: index.php?error=2'); 
}
else{
  $npwd=new_password(6);
  $sql = "update reservation".$DB_prefixtable."client set mdp='".$npwd."' where email='".$_POST['email']."'";
  $req = mysqli_query($db, $sql) or die('Erreur SQL !'.mysqli_error());  
  
  /*mail*/
  
   require('phpmailer/class.phpmailer.php');
   $mail = new PHPMailer();
   $mail->CharSet = "utf-8";
   $mail->IsHTML(true);
   $mail->From = "info@namtation.be";
   $mail->FromName = "NamTation";
   $mail->Subject = "Votre accès au module de réservation";
   
   $body="";
   $body=$body."Bonjour,<br><br>";
   $body=$body."Vous trouverez ci-dessous les paramètres qui vont permettront d'acc&eacute;der au système de r&eacute;servation de vos s&eacute;ances de Namtation :<br><br>";
   $body=$body.'Adresse : <a href="https://www.namtation.be/reservation">https://www.namtation.be/reservation</a><br>';
   $body=$body."Adresse mail : ".$_POST['email']."<br>";
   $body=$body."Mot de passe : ".$npwd."<br><br>";
   $body=$body."Vous pouvez à tout moment changer ce mot de passe en cliquant sur 'Mise à jour de vos données'.<br><br>";
   $body=$body."NamTation";
     
   
   $mail->Body = $body;
   $mail->AddAddress($_POST['email']);
   $mail->send();
  
  /*liam*/
  header('Location: index.php?message=1'); 
  
}
 




mysql_close(); 
?>