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 } ?> Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/ 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... Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219564 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(); } Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219573 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219581 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219584 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219590 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219592 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> Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219643 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219651 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219656 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. Link to comment https://forums.phpfreaks.com/topic/237333-unique-submit-buttons-wont-post/#findComment-1219659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.