Page 1 of 1

Unique Submit Buttons Won't Post

Posted: Tue May 24, 2011 2:14 pm
by unemployment
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
}

?>

Re: Unique Submit Buttons Won't Post

Posted: Tue May 24, 2011 2:37 pm
by jacek
unemployment wrote: Does my form need to be inside my foreach?
no.

But it isn't working because you have not given the form an action attribute.

Re: Unique Submit Buttons Won't Post

Posted: Tue May 24, 2011 2:45 pm
by unemployment
jacek wrote:
unemployment wrote: Does my form need to be inside my foreach?
no.

But it isn't working because you have not given the form an action attribute.
The action doesn't seem to be the problem as this isn't killing that page when I hit submit.
if (isset($_POST['join']))
{
	var_dump($_POST['join']);
	echo "works";
	die();
}

Re: Unique Submit Buttons Won't Post

Posted: Tue May 24, 2011 3:09 pm
by jacek
First, please use the code buttons when posting code on the forum ;)

Second, try moving the var_dump outside of the if block to see what post data you are actually getting.