ViciousC Posted January 3, 2008 Share Posted January 3, 2008 Stuck What Im looking for is the input amount from the form to change the variable $amount. this is what I have might be a little messy but everything works except the change. function train2() { global $userrow, $numqueries; $good =""; $bad =""; $amount =""; /********\ |Strength| \********/ if (isset($_POST["Train1"])) { $my_array = array( "<font color=Lime>You train hard!</font>+.1125<br>", //0 "<font color=Lime>You train hard!</font>+.0381<br>", //1 "<font color=Red>Pulled a muscle</font>-.1427<br>",//2 "<font color=#808080>Your tired and give no effort!</font>+.0016<br>",//3 "<font color=Lime>You train hard!</font>+.1021<br>", //4 "<font color=Lime>You train hard!</font>+.0888<br>", //5 "<font color=Red>Pulled a muscle</font>-.0921<br>",//6 "<font color=#808080>Your tired and give no effort!</font>+.0004<br>",//7 "<font color=Lime>You train hard!</font>+.0221<br>", //8 "<font color=Lime>You train hard!</font>+.0377<br>", //9 "<font color=Red>Pulled a muscle</font>-.0925<br>",//10 "<font color=#808080>Your tired and give no effort!</font>+.0012<br>",//11 "<font color=Lime>You train hard!</font>+.0465<br>", //12 "<font color=Lime>You train hard!</font>+.0842<br>", //13 "<font color=Red>Pulled a muscle</font>-.1039<br>",//14 "<font color=#808080>Your tired and give no effort!</font>+.0004<br>" ); for ($i=0; $i<=$amount; $i++){ $random = array_rand($my_array); $parola .= $my_array[$random]; $gained = $good - $bad; } $title = "train"; $page = " <table width=100%><tr><td class=title align=center>Train Results</td></tr>"; $page .= " <tr><td>$parola</td></tr>"; $page .= " <tr><td>You Gained: $gained Strength</tr></table>"; $page .= "<center><a href=index.php?do=train>BACK</a></center>"; $updatequery = doquery("UPDATE {{table}} SET energy=energy-25, stamina=stamina-12 WHERE id='".$userrow["id"]."' LIMIT 1", "users"); } else { $title = "train"; $page .= " <form action=\"index.php?do=train2\" method=\"post\">\n"; $page .= " <table width=90% border=1 align=center><tr><td align=center bgcolor=red colspan=2>TRAINING</td></tr>"; $page .= "<tr><td align=left>I want to train  <input type=text name="" size=3 maxlength=3>   times    <input type=\"submit\" name=\"Train1\" value=\"SUBMIT\" /></td></tr>"; $page .= " </table><br /><br /> "; $page .= "<center><a href=index.php?do=towninf>GO BACK</a></center>"; $page .= " </form>"; } display($page, $title); } Link to comment https://forums.phpfreaks.com/topic/84270-solved-need-help-input-to-change-a-variable/ Share on other sites More sharing options...
Daukan Posted January 3, 2008 Share Posted January 3, 2008 Post data in read into PHP's $_POST, and $_REQUEST vars. For security and less brittle code you should stay away form $_REQUEST vars. <?php $amount = $_POST['amount']; ?> Link to comment https://forums.phpfreaks.com/topic/84270-solved-need-help-input-to-change-a-variable/#findComment-429229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.