当我尝试使用“忘记密码”重设密码时,我的PHP项目中出现错误

时间:2019-10-15 10:56:08

标签: php html

当我填写邮件以重置密码时,我在页面上收到此错误: PHP error(The yellow part is the error)

有人知道我能做些什么来使其再次工作。

这是文件的PHP部分:

if(isset($_POST["submit"])) {
        $melding = "";
        $email = htmlspecialchars($_POST['e-mail']);

        // Hier genereren we een token en een timestamp
        $token = bin2hex(random_bytes(32));
        $timestamp = new DateTime("now");
        $timestamp = $timestamp->getTimestamp();
        //Hier slaan we het token voor deze klant in de database op
        include('../DBconfig.php');
        try {
            $sql = "UPDATE klant SET 'token' = ? WHERE 'email' = ?";
            $stmt = $verbinding->prepare($sql);
            $stmt = $stmt->execute(array($token, $email));
            if(!stmt) {
                echo "<script>alert('Kon niet opslaan in database.');
                location.href='../index.php?page=inloggen';</script>";
            }
        }catch(PDOException $e) {
            echo $e->getMessage();
        }
// Hier configureren we de URL van de wachtwoord_resetten-pagina
$url = sprintf("%s://s",isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='of-f'?'https':'http',$_SERVER['HTTP_HOST'].
dirname($_SERVER['PHP_SELF'])."/wachtwoord_resetten.php");

// Hier voegen we het token en de timestamp aan de URL toe
$url = $url."?token".$token."&timestamp=".$timestamp;

// Hier mailen we de URL naar de klant
include("../bibliotheek/mailen.php");
$onderwerp = "wachtwoord resetten";
$bericht = "<p>Als je je wachtwoord wilt resetten klik <a href=".$url.">hier</a></p>";
try {
    mailen($email, "klant", $onderwerp, $bericht);
    $melding = 'Open je mail om verder te gaan.';
} catch(Exception $e) {
    $melding = 'Kon geen mail versturen - ' + $mail->ErrorInfo;
}
echo "<div id='melding'>".$melding."</div>";
}

文件的html部分:

<!DOCTYPE html>
<html lang="nl">
<head>
    <title>Webshop</title>
    <link rel="stylesheet" href="../css/webshop.css" />
    <script src="https://www.google.com/recaptcha/api.js"
    async defer></script>
</head>
<body>
    <div class="content">
    <form name="Wachtwoord vergeten"
          method="POST" enctype="multipart/form-data" action="">
        <p id="page_titel">Nieuwe wachtwoord aanvragen</p>
        <input type="email" required name="e-mail" placeholder="e-mail" />
        <div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI">
        </div>
        <br/>
        <div class="icon_container">
        <input type="submit" class="icon" id="submit" name="submit" value="&rarr;" />
        </div>
        <a href="../index.php?page=inloggen">Terug</a>
        </form>
    </div>

如果您需要更多信息,请告诉我们。

0 个答案:

没有答案