从第一页重定向时,网页显示空白页

时间:2014-06-04 09:21:33

标签: php mysql

我有一个显示空白页面的表单。表单详细信息没有显示。这是一个空白页面。表格,以显示会员号,月份日期,金额等详细信息。但它是一个没有显示详细信息的空白页面代码有什么问题。

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

2 个答案:

答案 0 :(得分:0)

除了mysql_connect之外,使用PDO更安全。 只有在您发布表单时才会打印表单。

答案 1 :(得分:0)

如果您需要,请使用以下代码并进行测试。

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