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
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();
		}

Link to comment
Share on other sites

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>

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.