在文本框中没有显示数据库数据的占位符

时间:2019-07-05 21:07:57

标签: php html mysql sql database

我尝试将数据库中的数据获取到当前登录用户的文本框中,以更改其个人资料数据,但是

$sql = "SELECT * FROM klant where Email = ?";

似乎不起作用。但是当我使用$sql = "SELECT * FROM klant时 它可以工作,但是它从数据库中获取第一个用户,而不是当前登录的用户。我没有收到任何错误消息。

无论如何我都能使它正常工作吗?

<?php

if(!isset($_SESSION["ID"])&&($_SESSION["STATUS"]!="ACTIEF")){
    echo "<script> alert('U heeft geen toegang tot deze pagina.');
    location.href='../index.php'</script>";
}
try {
    $sql = "SELECT * FROM klant where Email = ?";
    $stmt = $verbinding->prepare($sql);
    $stmt->execute(array( $_SESSION["E-MAIL"] ));
    $resultaat = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (PDOEception $e) {
    echo $e->getMessage();
}
?>

<div class="content">
    <form method="POST" action="index.php?page=profiel_update">
        <p id="page_titel">Profiel editen</p>
        <label for="voornaam">Voornaam</label>
        <input type="text" required name="voornaam" value="<?php echo $resultaat['Voornaam']; ?>" />
        <label for="achternaam">Achternaam</label>
        <input type="text" required name="achternaam" value="<?php echo $resultaat['Achternaam']; ?>" />
        <label for="straat">Voornaam</label>
        <input type="text" required name="straat" value="<?php echo $resultaat['Straat']; ?>" />
        <label for="postcode">Postcode</label>
        <input type="text" required name="postcode" value="<?php echo $resultaat['Postcode']; ?>" />
        <label for="woonplaats">Woonplaats</label>
        <input type="text" required name="woonplaats" value="<?php echo $resultaat['Woonplaats']; ?>" />
        <label for="e-mail">E-Mail</label>
        <input type="email" required name="e-mail" value="<?php echo $resultaat['Email']; ?>" />
        <br/>
        <div class="icon_container">
            <input type="submit" class="icon" id="submit" name="submit" value="&rarr;" />
        </div>
        <a href="index.php?page=webshop">Terug</a>
    </form>
</div>

0 个答案:

没有答案