php - 文本框中不显示数据库数据的占位符
问题描述
我尝试将数据从我的数据库中获取到当前登录用户的文本框以更改他们的个人资料数据,但是
$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="→" />
</div>
<a href="index.php?page=webshop">Terug</a>
</form>
</div>
解决方案
推荐阅读
- javascript - Django CSRF 验证失败。请求中止。错误
- javascript - 如何在useState React Hooks中将对象连接到对象数组中的特定对象
- javascript - 在Vue.js 2.0中选中复选框时如何将类添加到父元素
- apache-spark - 为什么执行程序条目在 spark web ui 中不可见
- flutter - 在 PageView 中使用 video_player 出现 Flutter 性能问题/Jank
- grafana - Grafana 查询以每天从同一时间生成累积总和
- php - 如何使数组具有另一个数组中字符串的键和值?
- java - 运行 localhost:8080 时出现错误“Whitelabel Error Page”
- python - AWS lambda 使用 PyPDF2 打开 pdf
- angular - ESLint prefer-const 规则声明变量应该是 Const,即使它被重新分配