首页 > 解决方案 > 文本框中不显示数据库数据的占位符

问题描述

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

$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>

标签: phphtmlmysqlsqldatabase

解决方案


推荐阅读