[英]Webpage displays a blank page when redirected from the first page
我有一個顯示空白頁的表單。表單詳細信息沒有出現。 這是空白頁。 用於顯示諸如會員編號,月份日期,金額之類的詳細信息的表格。 但是它是空白頁,沒有顯示任何詳細信息代碼有什么問題。
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$db = "anthonys";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
mysql_select_db($db,$dbhandle) or die('cannot select db');
if(isset($_POST['update'])){
$uid=$_REQUEST['uid'];
$month=$_REQUEST['month'];
$date=$_POST['date'];
$amount=$_POST['amount'];
mysql_query("UPDATE payment SET uid='$uid',month ='$month', date='$date', amount='$amount' WHERE uid='$uid' and month='$month'") or die(mysql_error());
echo "<script>alert('Record Updated!!')</script>";
$myData= mysql_query("SELECT * FROM payment where uid='$uid' and month='$month'")or die(mysql_error());
while($record = mysql_fetch_assoc($myData))
{
?>
<section id="sheet" style="background-color: Transparent;">
<div id="content_inner">
<div id="col2">
<h2>PAYMENT RECEIPT</h2><br /><br />
<table border="0px" style="border-collapse:collapse; width:810px;" align="center">
<tr>
<td>
<form name="XIForm" id="XIForm" method="post" action="modifypay3.php">
<span style="float:right; width:500px;margin-top:-55px;">
<label type="text" name="uid" maxlength="50" size="30" class="label" >Membership No</label><br />
<input type="text" name="uid" value="<?php echo $record['uid'];?>"readonly><br /><br /></span>
<label type="text" name="month" maxlength="50" size="30" class="label">Month</label><br />
<input type="text" name="month" class="input" size="40" value="<?php echo $record['month']; ?>"> <br /><br />
<label type="text" name="date" maxlength="50" size="30" class="label">Date</label><br />
<input type="text" name="date" class="input" style="width:370px;" value="<?php echo $record['date']; ?>"><br /><br />
<label type="text" name="amount" maxlength="50" size="30" class="label">Amount Paid</label><br />
<input type="text" name="amount" class="input" size="39" value="<?php echo $record['amount']; ?>"> <br /><br />
<input type=hidden name=hidden value="<?php echo $record['uid'];?>"><br/><br/>
<input type="submit" name="submit" value="UPDATE" class="button" />
</form>
<?php }?>
<?php }?>
</body>
</html>
使用除mysql_connect之外的PDO更為安全。 僅當您發布表單時才打印該表單。
如果需要,請使用以下代碼進行測試。
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$db = "anthonys";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
mysql_select_db($db,$dbhandle) or die('cannot select db');
if(isset($_POST['submit'])){
$uid=$_REQUEST['uid'];
$month=$_REQUEST['month'];
$date=$_POST['date'];
$amount=$_POST['amount'];
mysql_query("UPDATE payment SET uid='$uid',month ='$month', date='$date', amount='$amount' WHERE uid='$uid' and month='$month'") or die(mysql_error());
echo "<script>alert('Record Updated!!')</script>";
};
$myData= mysql_query("SELECT * FROM payment where uid='$uid' and month='$month'")or die(mysql_error());
while($record = mysql_fetch_assoc($myData))
{?>
<section id="sheet" style="background-color: Transparent;">
<div id="content_inner">
<div id="col2">
<h2>PAYMENT RECEIPT</h2><br /><br />
<table border="0px" style="border-collapse:collapse; width:810px;" align="center">
<tr>
<td>
<form name="XIForm" id="XIForm" method="post" action="modifypay3.php">
<span style="float:right; width:500px;margin-top:-55px;">
<label type="text" name="uid" maxlength="50" size="30" class="label" >Membership No</label><br />
<input type="text" name="uid" value="<?php echo $record['uid'];?>"readonly><br /><br /></span>
<label type="text" name="month" maxlength="50" size="30" class="label">Month</label><br />
<input type="text" name="month" class="input" size="40" value="<?php echo $record['month']; ?>"> <br /><br />
<label type="text" name="date" maxlength="50" size="30" class="label">Date</label><br />
<input type="text" name="date" class="input" style="width:370px;" value="<?php echo $record['date']; ?>"><br /><br />
<label type="text" name="amount" maxlength="50" size="30" class="label">Amount Paid</label><br />
<input type="text" name="amount" class="input" size="39" value="<?php echo $record['amount']; ?>"> <br /><br />
<input type=hidden name=hidden value="<?php echo $record['uid'];?>"><br/><br/>
<input type="submit" name="submit" value="UPDATE" class="button" />
</form>
<?php }?>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.