Jump to content

[SOLVED] 2 forms, only 1 seems to be working?


MasterACE14

Recommended Posts

This should be really straight forward and working, but it's not, I'm sure it's something really simple I have overlooked.

 

Basically, There is 2 forms on the same page, and they both submit back to the same page they are on. Then 1 of 2 functions is chosen to run depending on what form was submitted.

 

It keeps running standard_supporterstatus(); no matter which of the 2 forms I submit.

 

here's the script(cut down to necessary code only):

<?php
if($userrow['SSused'] < 3) {
if(isset($_POST['act']) == "ss") {
	include "top.php";
		if($userrow['SScount'] > 0) {
			standard_supporterstatus($userrow['ID']);
			echo "You have successfully activated a Standard Supporter Status.";
		} else {
			echo "You do not have any Standard Supporter Status's in your Count. You can purchase a supporter status <a href=\"supporterstatus.php\">here</a>.";
		}
	exit;	
}

elseif(isset($_POST['act']) == "uss") {
	include "top.php";
		if($userrow['USScount'] > 0) {
			ultimate_supporterstatus($userrow['ID']);
			echo "You have successfully activated a Ultimate Supporter Status.";
		} else {
			echo "You do not have any Ultimate Supporter Status's in your Count. You can purchase a supporter status <a href=\"supporterstatus.php\">here</a>.";
		}
	exit;	
}
} else {
	include "top.php";
	echo "You have used all 3 of your Supporter Status bonus's for the week!";
	exit;
}
?>

		<tr>
			<td>
			<?php

			if($userrow['SScount'] > 0) {
				echo "<form action=\"ss.php\" method=\"post\">";
				echo "<input type=\"hidden\" name=\"act\" value=\"ss\" />";
				echo "<input type=\"submit\" value=\"Activate 1 Standard Supporter Status!\" />";
				echo "</form>";	
			} else {
				echo "You do not have any Standard Supporter Status's Ready to Activate!";
			}

			?>
			</td>
		</tr>

		<tr>
			<td>
			<?php

			if($userrow['USScount'] > 0) {
				echo "<form action=\"ss.php\" method=\"post\">";
				echo "<input type=\"hidden\" name=\"act\" value=\"uss\" />";
				echo "<input type=\"submit\" value=\"Activate 1 Ultimate Supporter Status!\" />";
				echo "</form>";	
			} else {
				echo "You do not have any Ultimate Supporter Status's Ready to Activate!";
			}

			?>
			</td>
		</tr>

 

Any help is appreciated.

 

Regards ACE

if you use my example it so easy mate.

 

Yep I used your example and it worked perfectly, thanks for the information, I shall use submit buttons like that more often.

 

Cheers.

 

maybe ought to change  name of the hidden field in the two form

 

echo "<input type=\"hidden\" name=\"act\" value=\"uss\" />";

 

to  another name like

echo "<input type=\"hidden\" name=\"act1\" value=\"uss\" />";

 

Thanks for the suggestion, But I like redarrow's idea of using the submit button for the PHP checks. Thanks for your advice none the less  :D

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.