timmah1 Posted December 10, 2008 Share Posted December 10, 2008 I have form on my front page. I have two different buttons, both with different names. Depending on which button you push, it takes you to the appropriate page. I have done this a thousand times, and for some reason, the form is just refreshing it self. Here is the top of the page <?php if($_POST['paypal']){ header("Location: " . $config_basedir . "orderform.php"); } if($_POST['credit']){ header("Location: " . $config_basedir . "billingInfo.php"); } else{ require("header.php"); ?> <form action="" method="post" enctype="application/x-www-form-urlencoded"> And my buttons <input name="paypal" type="image" value="submit" src="paypal_front.gif" /> <input name="credit" type="image" value="submit" src="creditCard_front.gif" /> Can anybody tell me why this page just refreshes? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/ Share on other sites More sharing options...
dezkit Posted December 10, 2008 Share Posted December 10, 2008 try if(isset($_POST['paypal'])){ Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711091 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 I've tried that, and I just tried again with the same results Your more than welcome to look at what I mean http://www.cheezyfries.net/vegasD/secure/ Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711094 Share on other sites More sharing options...
dezkit Posted December 10, 2008 Share Posted December 10, 2008 Can you post the code of the form page? Edit: This Order Form Is On A Secure Server For Your Protection No it's not! Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711097 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 Here is the complete code if(isset($_POST['paypal'])){ header("Location: " . $config_basedir . "orderform.php"); } if($_POST['authorize']){ header("Location: " . $config_basedir . "billingInfo.php"); } else{ require("header.php"); ?> <form action="" method="post" enctype="application/x-www-form-urlencoded"> <input type=hidden name=member value=1> <!--start primary page table--> <table width=100% cellpadding=0 cellspacing=0 border=0><tr><td> <center> </td></tr><tr><td> <center> <p style="margin-top:8px; width: 791px;"> <b><font color=FF0000>This Order Form Is On A Secure Server For Your Protection</font><br> Access information will be emailed to you immediately upon approval of your Transaction.</b> <p style="margin-top:8px"> <?php switch($_GET['error']) { case "1": echo "<font color=#FF0000><strong>Error - Nothing Selected<br />You must select at least one option.</font>"; break; case "taken": echo "<font color=#FF0000><strong>Username is already in use</font>"; break; case "ip": echo "<font color=#FF0000><strong>Your IP Address has already been signed up</font>"; break; } ?> <table width="750" border="0" align="center"> <tr valign="top"> <td width="400"> <!--start order form layout table--> <?php if($NBAactive) { ?> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <!--start NBA table--> <td class="orderHeader" align="center">NBA Basketball</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['nba'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='nba' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='nba' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NBA table--> <?php } ?> <?php if($NCAAFactive) { ?> <!--start NCAA Football table--> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <td class="orderHeader" align="center">College Football Specials</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['ncaaf'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='ncaaf' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='ncaaf' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NCAA Football table--> <?php } ?></td> <td width="0"> </td> <td width="400"> <?php if($NCAABactive) { ?> <!--start NCAA Basketball table--> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <td class="orderHeader" align="center">College Basketball Specials</td> </tr> <tr> <td> <? $buffer = ''; foreach ($itemCodes['ncaab'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='ncaab' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='ncaab' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NCAA Basketball table--> <?php } ?> <?php if($NFLactive) { ?> <!--start NFL table--> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <td class="orderHeader" align="center">NFL Pro Football Specials</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['nfl'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='nfl' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='nfl' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NFL table--> <?php } ?></td> </tr> <tr valign="top"> <td colspan="5"> <?php if($MLBactive) { ?> <!--start Ultimate table--> <table width="400" border="1" align="center" cellpadding="3" cellspacing="0"> <tr> <td class="orderHeader" align="center">Ultimate Lock Pick</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['ult'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='ult' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='ult' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--End MLB table--> <?php } ?></td> </tr> </table> </td> </tr> </table> <!--end order form layout table--> <input name="paypal" type="image" value="submit" src="paypal_front.gif" /> <input name="credit" type="image" value="submit" src="creditCard_front.gif" /> </form> <?php } require("footer.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711098 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 <?php if(isset($_POST['paypal'])){ header("Location: " . $config_basedir . "orderform.php"); }elseif(isset($_POST['credit'])){ header("Location: " . $config_basedir . "billingInfo.php"); } else{ require("header.php"); ?> <form action="" method="post" enctype="application/x-www-form-urlencoded"> Try that. Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711099 Share on other sites More sharing options...
dezkit Posted December 10, 2008 Share Posted December 10, 2008 Try changing <form action="" method="post" enctype="application/x-www-form-urlencoded"> to <form action="<?php echo $_SERVER['PHP_SELF'];" method="post" enctype="application/x-www-form-urlencoded"> Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711101 Share on other sites More sharing options...
dezkit Posted December 10, 2008 Share Posted December 10, 2008 Oh, you get a header error. Warning: Cannot modify header information - headers already sent by (output started at /home/cheezy/public_html/vegasD/secure/index.php:1) in /home/cheezy/public_html/vegasD/secure/index.php on line 3 Look on top of the page after you submit the form, there has to be nothing after or before the <?php ?> tags. Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711104 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 No go. If I just go to the directory http://www.cheezyfries.net/vegasD/secure/ and click on something then the button, it goes to http://www.cheezyfries.net/vegasD/secure/index.php Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711107 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 Why would I be getting a header error? Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711108 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 The top of my page is this now <?php require("header.php"); if(isset($_POST['paypal'])){ header("Location: " . $config_basedir . "orderform.php"); } if(isset($_POST['credit'])){ header("Location: " . $config_basedir . "billingInfo.php"); } ?> I know longer get the header error, but it don't post to the correct page either Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711118 Share on other sites More sharing options...
dezkit Posted December 10, 2008 Share Posted December 10, 2008 index.php <form action="process.php" method="post" enctype="application/x-www-form-urlencoded"> <input type=hidden name=member value=1> <!--start primary page table--> <table width=100% cellpadding=0 cellspacing=0 border=0><tr><td> <center> </td></tr><tr><td> <center> <p style="margin-top:8px; width: 791px;"> <b><font color=FF0000>This Order Form Is On A Secure Server For Your Protection</font><br> Access information will be emailed to you immediately upon approval of your Transaction.</b> <p style="margin-top:8px"> <?php switch($_GET['error']) { case "1": echo "<font color=#FF0000><strong>Error - Nothing Selected<br />You must select at least one option.</font>"; break; case "taken": echo "<font color=#FF0000><strong>Username is already in use</font>"; break; case "ip": echo "<font color=#FF0000><strong>Your IP Address has already been signed up</font>"; break; } ?> <table width="750" border="0" align="center"> <tr valign="top"> <td width="400"> <!--start order form layout table--> <?php if($NBAactive) { ?> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <!--start NBA table--> <td class="orderHeader" align="center">NBA Basketball</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['nba'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='nba' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='nba' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NBA table--> <?php } ?> <?php if($NCAAFactive) { ?> <!--start NCAA Football table--> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <td class="orderHeader" align="center">College Football Specials</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['ncaaf'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='ncaaf' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='ncaaf' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NCAA Football table--> <?php } ?></td> <td width="0"> </td> <td width="400"> <?php if($NCAABactive) { ?> <!--start NCAA Basketball table--> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <td class="orderHeader" align="center">College Basketball Specials</td> </tr> <tr> <td> <? $buffer = ''; foreach ($itemCodes['ncaab'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='ncaab' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='ncaab' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NCAA Basketball table--> <?php } ?> <?php if($NFLactive) { ?> <!--start NFL table--> <table width="100%" cellpadding="3" border="1" cellspacing="0"> <tr> <td class="orderHeader" align="center">NFL Pro Football Specials</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['nfl'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='nfl' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='nfl' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--end NFL table--> <?php } ?></td> </tr> <tr valign="top"> <td colspan="5"> <?php if($MLBactive) { ?> <!--start Ultimate table--> <table width="400" border="1" align="center" cellpadding="3" cellspacing="0"> <tr> <td class="orderHeader" align="center">Ultimate Lock Pick</td> </tr> <tr> <td> <?php $buffer = ''; foreach ($itemCodes['ult'] as $fieldName => $val){ list($descr, $price) = explode("|", $val); $price = ($price == "N/A")? "N/A": sprintf("%.2f", $price); if($price == "N/A") { $buffer .= "<input type='radio' name='ult' value='$fieldName' readonly> $descr: $price<br>\n"; } else { $buffer .= "<input type='radio' name='ult' value='$fieldName'> $descr: $price<br>\n"; } } echo $buffer; ?></td> </tr> </table> <!--End MLB table--> <?php } ?></td> </tr> </table> </td> </tr> </table> <!--end order form layout table--> <input name="paypal" type="image" value="submit" src="paypal_front.gif" /> <input name="credit" type="image" value="submit" src="creditCard_front.gif" /> </form> <?php } require("footer.php"); ?> process.php <?php if($_POST['paypal']){ header("Location: " . $config_basedir . "orderform.php"); } if($_POST['credit']){ header("Location: " . $config_basedir . "billingInfo.php"); } else{ require("header.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711121 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 ok, doing that works. But it seems now, nothing is being posted I have this on top of my orderfom.php and billingInfo.php page if (!array_key_exists("nba", $_POST) && !array_key_exists("ult", $_POST) && !array_key_exists("nfl", $_POST) && !array_key_exists("ncaaf", $_POST) && !array_key_exists("ncaab", $_POST) ){ header("Location: " . $config_basedir . "index.php?error=1"); } And it constantly post back to the index.php with error Error - Nothing SelectedYou must select at least one option. It's starting to seem that the form itself isn't working[/] Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711126 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 <?php $error = isset($_GET['error'])?$_GET['error']:0; switch($error) { Try using that instead. That way you know if there is not an error it will not run any of the switches. Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711462 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Author Share Posted December 10, 2008 Thank you for the response premiso I figured out a different approach, and that's using sessions to fill in my form with the appropriate variables. I'm going to try your method on a different set of pages, because for the life of me, I have no idea why the form wasn't processing. Thanks again for the response Quote Link to comment https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/#findComment-711484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.