Files
Roosters/php/setMail.php
T
2026-06-17 11:55:21 +02:00

34 lines
1.1 KiB
PHP

<?php
SESSION_START();
$name = $_SESSION['name'];
require('connect.php');
$mail = $_POST['mail'];
if(!filter_var($mail, FILTER_VALIDATE_EMAIL)){
header("Location: ../mail/?mf=1");
}
$characters = '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ?!';
$code = '';
for ($i = 0; $i < 12; $i++) {
$code .= $characters[rand(0, strlen($characters) - 1)];
}
$query = "UPDATE `pass_forgot` SET `mail_new`='$mail', `confirm_mail`='$code' WHERE `name`='$name'";
mysql_query($query, $connection) or die('Er is een fout opgetreden');
$headers = "From: Sondervick College <rooster@kennyboy.nl>\r\n";
$headers .= "Content-Type: text/html";
$message = "<html><body>Beste $name,<br><br>Om uw e-mail adres te activeren klikt u op de onderstaande link:<br><a href='http://localhost:8080/php/confirmMail.php?code=$code'>Bevestigen</a>";
$message .= "<br><br> of u vult deze code in op de website:<br><h3>$code</h3></body></html>";
mail($mail, 'Sondervick Bevestiging', $message, $headers) or die("Error");
$_SESSION['mail']=0;
$_SESSION['confirm']=1;
header("Location: ../mail/confirm/");
?>