Jump to content

Unique Submit Buttons Won't Post


unemployment

Recommended Posts

I can't figure out why my $_POST['join'] isn't working.  Does my form need to be inside my foreach?

 

<?php

if(is_admin($user_info['uid'], $info['companyid']) === false)
{
if (isset($_POST['join']))
{
	echo "works";
	die();
}

$companies = fetch_company_by_name($info['cname']);

?>
<table class="feed pts pbl">
<?php

foreach ($companies as $company)
{
	?>
	<tr class="mbm">
		<td>
			<form method="post" id="ccreateform" class="man">
				<input type="submit" name="join[<?php echo $company['companyid']; ?>]" value="Join" />
			</form>
		</td>
	</tr>
	<?php
} 

?>
</table>
<?php
}

?>

Link to comment
https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/
Share on other sites

Debug the $_POST array. Use var_dump to check the values it contains...

 

Nothing is being generated.  Hitting the submit button just refreshes the page, which it shouldn't if my post if statement was running properly because I have the page set to die. 

 

if (isset($_POST['join']))
		{
			var_dump($_POST['join']);
			echo "works";
			die();
		}

You're looking for the value "join" but are submitting "joinid".  Why not put company id in another field?

<form method="post" id="ccreateform" class="man">
<input type="hidden" name="companyid" value="<?php echo $company['companyid']; ?>" />
<input type="submit" name="join" value="Join" />
</form>

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.