Jump to content

[SOLVED] Form refreshing


timmah1

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/136302-solved-form-refreshing/
Share on other sites

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");
?> 

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

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.

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

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");
?>

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[/]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.