下面的代码有 8 个包含用户注册数据的 $_POST 变量。下面的代码还具有促销代码文本字段,当用户输入促销代码并尝试更新时,我丢失了包含用户注册数据的 8 个 $_POST 变量的值。我想知道是否有办法不丢失这些数据?
<?php
session_start();
//Create mysql connect variable
$conn = mysql_connect('host', 'root', 'raycharles');
//kill connection if error occurs
if(!$conn){
die('Error: Unable to connect.' . '<br>' . mysql_error());
}
//connect to mysql database
mysql_select_db("wibldard", $conn);
//GET PROMO CODES FROM DB
$promo_results = mysql_query("SELECT * FROM promo",$conn);
while($promo_row = mysql_fetch_array($promo_results)){
echo $promo_row['promo_code'];
}
if(isset($_GET['promo'])){
echo $_GET['promo'];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- JAVASCRIPT -->
<script type="text/javascript" src="js/jquery.js"></script>
<!-- STYLES & FONTS -->
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--JQUERY-->
<script type="text/javascript">
$(document).ready(function(){
$("#mainsearchfield").Watermark("");
});
</script>
</head>
<body>
<div id="main-container">
<?php include('inc/menu.inc.php'); ?>
<div id="body-container" style="padding-bottom:150px; height:800px;">
<div style="height:100px; margin:0px auto;">
<img class="reg-step" style="width:100%;" src="images/step2.png">
</div>
<?php
//echo 'e-mail :' . $_POST['email'] . '<br/>' . 'password :' . $_POST['password'] . '<br/>' . 'city: ' . $_POST['city'] . '<br/>' . 'state: ' . $_POST['state'] . '<br/>' . 'phone: ' . $_POST['phone'] . '<br/>' . 'first name: '. $_POST['fname'] . '<br/>' . 'last name: ' . $_POST['lname'] . '<br/>company: ' . $_POST['company-name'] ;
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $_POST['password'];
$_SESSION['city'] = $_POST['city'];
$_SESSION['state'] = $_POST['state'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['first'] = $_POST['fname'];
$_SESSION['last'] = $_POST['lname'];
$_SESSION['compname'] = $_POST['compname'];
?>
<span style="font-size:22px; color:blue; font-weight:bold; margin-left:100px;"> Invoice </span>
<div style="width:900px; height:500px; border:1px solid #ddd; margin-left:100px;">
<table id="registration-table1">
<!-- Results table headers -->
<tr style="background-color:lightblue;">
<th>Date</th>
<th>Product</th>
<th style="width:50px;">Qty</th>
<th>Cost</th>
</tr>
<tr>
<td style="width:120px;"><?php echo date("m/d/y");?></td>
<td style="width:570px; text-align:left; padding-left:10px;">
<a href="#">Apples</a>
</td>
<td style="text-align:center; padding-bottom:120px;">1</td>
<td style="width:150px; padding-bottom:120px; text-align:center;">$59.99</td>
</tr>
</table>
<div style="float:left; width:350px; font-size:12px; padding:10px;">*An order confirmation e-mail will be sent out to the address provided upon payment authorization.</div>
<table id="registration-table2">
<tr>
<td style="font-weight:bold; width:140px; padding:10px; padding-right:20px;">Promo Code:</td>
<td class="table2-cell">
<form method="get" action="registernewstep2.php">
<input name="promo" style="width:90px; margin-right:7px; margin:5px;" type="text" /><br/>
<input type="submit" style="margin-bottom:5px;" value="update"/>
</form>
</td>
</tr>
<tr>
<td class="table2-heading-cell">Delivery:</td>
<td class="table2-cell"><i>Electronic</i></td>
</tr>
<tr>
<td class="table2-heading-cell">Shipping:</td>
<td class="table2-cell">$0.00</td>
</tr>
<tr>
<td class="table2-heading-cell">Tax:</td>
<td class="table2-cell">$0.00</td>
</tr>
<tr>
<td class="table2-heading-cell">Total:</td>
<td class="table2-cell">$59.99</td>
</tr>
<tr>
<td style="font-weight:bold; padding:10px; border:none;"></td>
<td style="text-align:center; border:none; padding-top:20px;">
<!--CHECKOUT BUTTON-->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="johnnycage9@gmail.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="apples">
<input type="hidden" name="item_number" value="1701">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="tax_rate" value="0.000">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_SM.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_SM.gif" style="border:1px solid #fff;" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</td>
</tr>
</table>
</div>
<?php include('inc/footer.inc.php');
echo'
</div>
</body>
</html>';