php - Promo code form unsetting user registration data -
the code below has 8 $_post variables containing user registration data. code below features promo code text field, when users enter promo code , try update, lose values of 8 $_post variables contained user registration data. wondering if there way not lose data?
<?php session_start(); //create mysql connect variable $conn = mysql_connect('host', 'root', 'raycharles'); //kill connection if error occurs if(!$conn){ die('error: unable connect.' . '<br>' . mysql_error()); } //connect mysql database mysql_select_db("wibldard", $conn); //get promo codes db $promo_results = mysql_query("select * 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 sent out 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 - safer, easier way 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>';
the $_post variables "posted" page displayed, when user enters , submits promo code, you're not posting values you're missing.
to that, you'll need add hidden fields form being submitted. form field names have same $_post variable, , value of each field should value posted field this:
<form method="get" action="registernewstep2.php"> <input type="hidden" name="email" value="<?php echo $_post['email'>; ?>"/> <input type="hidden" name="password" value="<?php echo $_post['password'>; ?>"/> <input type="hidden" name="city" value="<?php echo $_post['city'>; ?>"/> <input type="hidden" name="state" value="<?php echo $_post['state'>; ?>"/> <input type="hidden" name="phone" value="<?php echo $_post['phone'>; ?>"/> <input type="hidden" name="fname" value="<?php echo $_post['fname'>; ?>"/> <input type="hidden" name="flname" value="<?php echo $_post['flname'>; ?>"/> <input type="hidden" name="compname" value="<?php echo $_post['compname'>; ?>"/> <input name="promo" style="width:90px; margin-right:7px; margin:5px;" type="text" /><br/> <input type="submit" style="margin-bottom:5px;" value="update"/> </form>
Comments
Post a Comment