Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/229795-_post-not-getting-sent/
Share on other sites

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

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.

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>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.