McBryver Posted March 6, 2011 Share Posted March 6, 2011 Hello, My script here is not sending POST vars from form to script. I can't figure it out. Form: <form action="train2.php" method="POST"> <tr> <td colspan="4"><center><img src="pic/toppage16.gif" /></center></td> </tr> <TR> <TD><FONT COLOR="white">Reassign Miners</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength="8" value="0" name="miner>"</FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Normal Attackers</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength="8" value="0" name="atsold"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Normal Defenders</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size=6 maxlength=8 value=0 name="defsold"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Reassign Covert Agents</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD> <TD align=middle><FONT COLOR="white"><INPUT size=6 maxlength=8 value=0 name="spy"></FONT></TD> </TR> <TR> <TD><FONT COLOR="white">Anti Covert Agents</FONT></TD> <TD align=right><FONT COLOR="white">0 Naquadah</FONT></TD><TD align=middle><FONT COLOR="white"><INPUT size="6" maxlength=8 value=0 name="spykiller"></FONT></TD></TR> <TR> <TD align=middle colSpan=3><FONT COLOR="white"><INPUT type="submit" value="UnTrain!" name="untrain"> </FONT> </TD> </form> <?php if(isset($_POST['untrain'])){ die($_POST['miner']); $miners = securevar($_POST['miner']); $nattackers = securevar($_POST['atsold']); $ndefenders = securevar($_POST['defsold']); $covertunits = securevar($_POST['spy']); $anticovertunits = securevar($_POST['spykiller']); $totalunits+=$miners; $totalunits+=$nattackers; $totalunits+=$ndefenders; $totalunits+=$covertunits; $totalunits+=$anticovertunits; if($totalunits>=1){ $q = "UPDATE `accountinfo_db` SET `miners_1` = `miners_1`-'$miner', `attackers_1` = `attackers_1`-'$natta', `defenders_1` = `defenders_1`-'$ndefe', `covertagents` = `covertagents`-'$cover', `anticovertagents` = `anticovertagents`+'$antic', `untrainedunits` = `untrainedunits`+'$totalunits' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); if(isset($res)){ header("Location: train.php?strmsg=".$totalunits."Troops Untrained! For 0 Naquadah."); } }else{ header("Location: train.php?strmsg=You must enter atleast 1 troop to be un-trained!"); } } ?> when I die($_GET['miner'); nothing is outputed even tho I submited the data. Thank you, Brian Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/ Share on other sites More sharing options...
jcbones Posted March 6, 2011 Share Posted March 6, 2011 This is why. Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183666 Share on other sites More sharing options...
Pikachu2000 Posted March 6, 2011 Share Posted March 6, 2011 You have a misplaced quote here: name="miner>"</FONT>. Make the edits I've commented in the code below and post it's output. <?php echo '<pre>'; print_r($_POST); echo '</pre>'; // <---- ADD THIS LINE if(isset($_POST['untrain'])){ die($_POST['miner']); // <---- REMOVE THIS LINE Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183667 Share on other sites More sharing options...
McBryver Posted March 6, 2011 Author Share Posted March 6, 2011 Ok here is what I get from that: Array ( [miner>] => 1 [atsold] => 0 [defsold] => 0 [spy] => 0 [spykiller] => 0 [untrain] => UnTrain! ) Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183764 Share on other sites More sharing options...
redarrow Posted March 7, 2011 Share Posted March 7, 2011 where the form, The 0 mean no post, The 1 means posted! Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183777 Share on other sites More sharing options...
jcanker Posted March 7, 2011 Share Posted March 7, 2011 What everyone is trying to tell you is that the line die($_POST['miner'] actually kills further execution of the script, so nothing else gets done. It's not that you're not receiving the $_POST array (your response to Pikachu2000's script demonstrates that). It's that you stop the script from executing in the first line of the if(isset($_POST['untrain'])) block. Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183778 Share on other sites More sharing options...
redarrow Posted March 7, 2011 Share Posted March 7, 2011 try this form and give post redults, you ned to realy learn to tidy your code up, it bad very bad i broke a finger nail <form action="train2.php" method="POST"> <tr> <td colspan="4"> <center> <img src="pic/toppage16.gif" /> </center> </td> </tr> <tr> <td> <font color="white"> Reassign Miners </font> </td> <td align="right"><font color="white">0 Naquadah</font></td> <td align="middle"> <font color="white"> <input size="6" maxlength="8" value="0" name="miner"> </font> </td> </tr> <tr> <tr> <font color="white"> Reassign Normal Attackers </font> </td> <td align="right"> <font color="white"> 0 Naquadah </font> </td> <td align="middle"> <font color="white"> <input size="6" maxlength="8" value="0" name="atsold"> </font> </td> </tr> <tr> <td> <font color="white"> Reassign Normal Defenders </font> </td> <td align="right"><font color="white">0 Naquadah</font></td> <td align="middle"><font color="white"> <input size="6" maxlength="8" value="0" name="defsold"></font></td> </tr> <tr> <td><font color="white">Reassign Covert Agents</font></td> <td align="right"><font color="white">0 Naquadah</font></td> <td align="middle"><font color="white"> <input size="6" maxlength="8" value="0" name="spy"></font></td> </tr> <tr> <td><font color="white">Anti Covert Agents</font></td> <td align="right"> <font color="white"> 0 Naquadah </font> </td> <td align="middle"> <font color="white"> <input size="6" maxlength="8" value="0" name="spykiller"></font></td></tr> <tr> <td align="middle" colspan="3"> <font color="white"> <input type="submit" value="UnTrain!" name="untrain"> </font> </td> </form> Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183784 Share on other sites More sharing options...
Pikachu2000 Posted March 7, 2011 Share Posted March 7, 2011 You didn't fix the misplaced quote I pointed out earlier if the print_r() shows the result you posted. Look carefully at the first array key: [miner>] => 1 If you had error reporting set and display errors on, you would have gotten a warning regarding that when you tried to use the array element. Quote Link to comment https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/#findComment-1183799 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.