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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.