我正在处理的 PHP 页面出现问题。
我有一个 list.php,它从 MySQL 数据库调用数据,还有一个 config.php 作为我的数据库的连接页面。下面是我的 edit.php 页面,当我查看它时,它完全是空白的。我的代码哪里出错了?
URL 字符串 http://localhost/example/edit.php?id=382 (应该调用 382 的客户端 ID 进行编辑)`
<html>
<body>
<?php
include('config.php');
if(isset($_GET['cx_id']))
{
$id=$_GET['cx_id'];
if(isset($_POST['submit']))
{
$name=$_POST['Name'];
$address=$_POST['Address'];
$query3=mysqli_query("update restrictedkeys set Name='$name', Address='$address' where cx_id='$id'");
if($query3)
{
header('location:list.php');
}
}
$query1=mysqli_query("select * from restrictedkeys where cx_id='$id'");
$query2=mysqli_fetch_array($query1);
?>
<form method="post" action="">
Name:<input type="text" name="name" value="<?php echo $query2['Name']; ?>" /><br />
Address:<input type="text" name="address" value="<?php echo $query2['Address']; ?>" /><br /><br />
<br />
<input type="submit" name="submit" value="update" />
</form>
<?php
}
?>
</body>
</html>
最佳答案
足够简单。仅当满足以下条件时才会打印您的表单:
if(isset($_GET['cx_id']))
{
由于网址是http://localhost/example/edit.php?id=382 ,实在不行。
将其更改为 http://localhost/example/edit.php?ctx_id=382你可能会得到一些不同的结果。
关于php - 如何调试导致白屏的 PHP/HTML 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40731044/