Unique Submit Buttons Won't Post

Ask about a PHP problem here.
Post Reply
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Unique Submit Buttons Won't Post

Post 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
}

?>
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Unique Submit Buttons Won't Post

Post 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.
Image
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Unique Submit Buttons Won't Post

Post 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();
}
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Unique Submit Buttons Won't Post

Post 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.
Image
Post Reply