<?php

require_once("config/config.php");
require_once("foo/functions.php");
dbconnect();


if ($_SERVER['REQUEST_METHOD'] === 'POST') {

$email = $_POST['email'];
if ($_POST['email'] == "") { redirect('forgotten-password.php?error=' . urlencode('Enter your Account Email!'));}
elseif(email_exist($_POST['email'])) {
$token = getRandomString(32);
update_token($token, $email);
mailresetlink($email,$token);
redirect('forgotten-password.php?msg=' . urlencode('Please check your email for the reset link!'));
}else{
redirect('forgotten-password.php?error=' . urlencode('Email address is not registered!'));
}
}

?>