unemployment Posted May 24, 2011 Share Posted May 24, 2011 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 } ?> Quote Link to comment Share on other sites More sharing options...
Adam Posted May 24, 2011 Share Posted May 24, 2011 Debug the $_POST array. Use var_dump to check the values it contains... Quote Link to comment Share on other sites More sharing options...
unemployment Posted May 24, 2011 Author Share Posted May 24, 2011 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(); } Quote Link to comment Share on other sites More sharing options...
TOA Posted May 24, 2011 Share Posted May 24, 2011 I'd check the form then, sounds like nothing is being POSTed. Quote Link to comment Share on other sites More sharing options...
Adam Posted May 24, 2011 Share Posted May 24, 2011 Place it outside of your isset() check for $_POST['join']. If it weren't getting there before, placing a var_dump() within it won't make any difference. Quote Link to comment Share on other sites More sharing options...
unemployment Posted May 24, 2011 Author Share Posted May 24, 2011 Place it outside of your isset() check for $_POST['join']. If it weren't getting there before, placing a var_dump() within it won't make any difference. Post['join'] is not being set. Which I really don't understand why. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 24, 2011 Share Posted May 24, 2011 You probably have an open <form> tag before that point on your page or some other broken html that is making the form(s) invalid in the code you did post. Quote Link to comment Share on other sites More sharing options...
Drummin Posted May 24, 2011 Share Posted May 24, 2011 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> Quote Link to comment Share on other sites More sharing options...
Adam Posted May 24, 2011 Share Posted May 24, 2011 He's not submitting joinid, it's join[id] - an array. Quote Link to comment Share on other sites More sharing options...
unemployment Posted May 24, 2011 Author Share Posted May 24, 2011 He's not submitting joinid, it's join[id] - an array. I actually fixed the issue based on the suggestion with the hidden input. Looks like it wasn't taking my array. Quote Link to comment Share on other sites More sharing options...
Drummin Posted May 24, 2011 Share Posted May 24, 2011 He's not submitting joinid, it's join[id] - an array.Sure, I know that, but he's looking for $_POST['join']. I was just pointing out that there is an id being added to the join name. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.