<?php
session_start();
require_once('./config.php');
$t=time();
$idvalidation=md5(str_shuffle($_POST['user'].$_POST['firstname'].$t));
$req=$bdd->prepare('UPDATE users SET idvalidation=:idvalidation WHERE username=:user');
$req->execute(array('idvalidation'=>$idvalidation,'user'=>$_POST['user']));
$req->CloseCursor();
if(isset($_POST['user'])){
$email = $_POST['mail'];
$message = 'Welcome to our website'.$_POST['firstname'].' '.$_POST['lastname'].'<br>
Your username is '.$_POST['user'].'
This is your validation link<a href="http://www.monsite.fr/validation.php?id="'.$idvalidation.'" >click here</a>.';
$destinataire = $email;
$objet = "Registration on MonSite.fr" ;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-
1' . "\r\n";
$headers .= 'From: monsite@monsite.fr' . "\r\n";
if ( mail($destinataire, $objet, $message, $headers)){
echo "mail successfully sent";
}else{
return 'mail failed to be sent';
}
}else{
return 'mail failed to be sent';
}
?>
|