marmite Posted April 23, 2007 Share Posted April 23, 2007 Sorry for all the posts today, coming to the end of my project (i hope) I can't get a basic form submit to work! FORM CODE <? while ($row=mysql_fetch_assoc($result3)) { ?> <tr> <form action="/cart.php" method="post" id="mycart"> <td id="normal"><object id='cart_pkg' name="cart_pkg"><? echo $row['packaging_desc']; ?></object></td> <td id="normal"><object id='cart_msg' name="cart_msg"><? echo $row['packaging_message']; ?></object></td> <td id="normal" align="center"><object id='cart_qty' name="cart_qty"><? echo $row['packaging_quantity']; ?></object></td> <td id="normal" align="center"><object id='cart_cello' name="cart_cello"><? echo $row['packaging_cello']; ?></object></td> <td id="normal" align="center">£<object id='cart_prc' name="cart_prc"><? echo number_format($row['packaging_price'],2,'.',''); ?></object></td> <td id="normal"><input name="qty" type="text" id="qty" size="3" /></td> <td id="normal"><input type="submit" value="Go!" id="submit5" name="submit5"></td> </form> </tr> <? } ?> PROCESSING CODE if ($_POST['submit5']) { $_SESSION['test']="abc"; } else { $_SESSION['test']="222"; } I then output $_SESSION['test'] to /cart.php and it always comes out as 222. So the form is not getting POSTed. I've tried with a submit button instead of an image. I've tried calling the submit "submit5" and referencing that instead of the whole form (mycart). My only thought is that the multiple submits (one per line of the table) is screwing things up... or I'm doing something stupid... Grateful for any help Emma Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/ Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 whats the results of print_r($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236261 Share on other sites More sharing options...
marmite Posted April 23, 2007 Author Share Posted April 23, 2007 Just "Array()" (I did this on the initiating page only and literally pasted "print_r($_POST);" - is that what you meant me to do?) Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236265 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 just before the if ($_POST['submit5']) { it should say Array(), then click the submit button whats it say now ? Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236269 Share on other sites More sharing options...
marmite Posted April 23, 2007 Author Share Posted April 23, 2007 Confused... it doesn't say anything cos it goes to /cart.php... when i change the form action to bulkview.php (initiating page), I get: Array ( [qty] => 2 [submit5] => go! ) Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236276 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 i don't know what cart.php or bulkview.php are! i assume if ($_POST['submit5']) { $_SESSION['test']="abc"; } else { $_SESSION['test']="222"; } is in cart.php! in which case you should of changed it to print_r($_POST); if ($_POST['submit5']) { $_SESSION['test']="abc"; } else { $_SESSION['test']="222"; } Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236281 Share on other sites More sharing options...
marmite Posted April 23, 2007 Author Share Posted April 23, 2007 OK, sorry. So, does: Array ( [qty] => 2 [submit5] => go! ) mean anything to you? (I changed the form action to go to itself, and this is what I got: qty is the input field in the form, go! is the value of the submit). I'm figuring: 1) None of the form "objects" have any values in this posted array (I was hoping that cart_pkg and all the other objects would have values stored here 2) POST is clearly working in some capacity, so why isn't it triggering if ( $_POST['submit5'] ) ? ARGH! Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236289 Share on other sites More sharing options...
marmite Posted April 23, 2007 Author Share Posted April 23, 2007 I'm so stupid. I had the POST if statement on the wrong page. Thanks for your help. I would tick "solved" but I still can't find it. Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236309 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 Solved is on the bottom left, if its not their i won't worry (if its not you find you can't edit your first post either! Quote Link to comment https://forums.phpfreaks.com/topic/48323-really-basic-_post-not-working-please-help/#findComment-236391 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.