Cyph Posted April 8, 2011 Share Posted April 8, 2011 Ok, so I want to load results out of a form in the same page. This shouldn't be a problem. Trying to get it into same page as where the form is, I think the code will make clear what I want to have done. Have a little experience with PHP, and trying to learn by doing stuff like this. Expect its something really simple. <HTML> <HEAD> <title>Pet EXP Calculator</title> <style type="text/css"> .Note { font-size: xx-small; } </style> </HEAD> <body> <Table border="0"> <?php if(isset($_POST['submit'])) { $PetLVL = $_POST['PetLVL']; $PetLoyal = $_POST['PetLoya']; $PetEXP = $_POST['PetEXP']; $MobLVL = $_POST['MobLVL']; echo ($PetLVL); } ?> <form action="<?=$_SERVER['PHP_SELF']?>"> <tr height="20"> <TD width="100"> Pet Level:</td><td width="70"><input name="PetLVL" type='text' id="PetLVL" size="3" maxlength="3"></input></td> <td width="100"> Pet Loyalty:</td><td> <select name="PeyLoyal" id="PetLoyal"> <option>0-50</option> <option>51-150</option> <option>151-500 <option>501-999</option></option></select></td><tr> <td>Current EXP Pet:</td> <td><input name="PetEXP" type='text' id="PetEXP" size="8" maxlength="8"></input> </td> <td class="Note"> *input the EXP your pet has in stats screen. </td> </tr> </tr> <tr height="20"> <td width="100">Monster Level:</td><TD><input name="MobLVL" type='text' id="MobLVL" size="3" maxlength="3"></input></td> <td class="note">*Add ? monsters as level 150</td> </tr> <tr> <td> <input name="submit" type="submit" value="submit"> </td> </tr> </form> </table> </body> </HTML> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 Explain what you want to do with the form data. Do you want it echoed in the form fields after the form is submitted or . . . ? But in any event, make this: <form action="<?=$_SERVER['PHP_SELF']?>"> Into this: <form action="" method ="post"> Quote Link to comment Share on other sites More sharing options...
Cyph Posted April 8, 2011 Author Share Posted April 8, 2011 I did that, no change yet. And I want to use the information here to make calculations and end up echoing it on the same page above or under the form. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 I don't see anywhere in the code where you attempt to echo the values . . . Quote Link to comment Share on other sites More sharing options...
Cyph Posted April 8, 2011 Author Share Posted April 8, 2011 Right now I only got 1 echo, since its not working yet I can't go and make all the calculations. Need tp get it echod first. echo ($PetLVL);} Thats the only echo atm. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 To make sure the $_POST array is populated with the values you think it should have, replace that echo with this and see what it returns when the form is submitted. echo '<pre>'; print_r($_POST); echo '</pre>'; Quote Link to comment Share on other sites More sharing options...
Cyph Posted April 8, 2011 Author Share Posted April 8, 2011 Nothing seems to be happening still. http://pikorimugadgets.nl/PWI/Pet_Calc.php Link to the file at the moment. And the code looks like this now: <?php if(isset($_POST['submit'])) { $PetLVL = $_POST['PetLVL']; $PetLoyal = $_POST['PetLoya']; $PetEXP = $_POST['PetEXP']; $MobLVL = $_POST['MobLVL']; echo '<pre>';print_r($_POST);echo '</pre>'; } ?> <form action="" method="post"> <tr height="20"> <TD width="100"> Pet Level:</td><td width="70"><input name="PetLVL" type='text' id="PetLVL" size="3" maxlength="3"></input></td> <td width="100"> Pet Loyalty:</td><td> <select name="PeyLoyal" id="PetLoyal"> <option>0-50</option> <option>51-150</option> <option>151-500 <option>501-999</option></option></select></td><tr> <td>Current EXP Pet:</td> <td><input name="PetEXP" type='text' id="PetEXP" size="8" maxlength="8"></input> </td> <td class="Note"> *input the EXP your pet has in stats screen. </td> </tr> </tr> <tr height="20"> <td width="100">Monster Level:</td><TD><input name="MobLVL" type='text' id="MobLVL" size="3" maxlength="3"></input></td> <td class="note">*Add ? monsters as level 150</td> </tr> <tr> <td> <input name="submit" type="submit" value="submit"> </td> </tr> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 Remove it from the conditional. In other words, move the closing curly } brace above the echo '<pre>'; etc. Then fill in the form and submit it again. Quote Link to comment Share on other sites More sharing options...
Cyph Posted April 8, 2011 Author Share Posted April 8, 2011 <?php if(isset($_POST['submit'])) { $PetLVL = $_POST['PetLVL']; $PetLoyal = $_POST['PetLoya']; $PetEXP = $_POST['PetEXP']; $MobLVL = $_POST['MobLVL']; } echo '<pre>';print_r($_POST);echo '</pre>'; ?> <form action="" method="post"> <tr height="20"> <TD width="100"> Pet Level:</td><td width="70"><input name="PetLVL" type='text' id="PetLVL" size="3" maxlength="3"></input></td> <td width="100"> Pet Loyalty:</td><td> <select name="PeyLoyal" id="PetLoyal"> <option>0-50</option> <option>51-150</option> <option>151-500 <option>501-999</option></option></select></td><tr> <td>Current EXP Pet:</td> <td><input name="PetEXP" type='text' id="PetEXP" size="8" maxlength="8"></input> </td> <td class="Note"> *input the EXP your pet has in stats screen. </td> </tr> </tr> <tr height="20"> <td width="100">Monster Level:</td><TD><input name="MobLVL" type='text' id="MobLVL" size="3" maxlength="3"></input></td> <td class="note">*Add ? monsters as level 150</td> </tr> <tr> <td> <input name="submit" type="submit" value="submit"> </td> </tr> </form> That is what I got now, thxs for being so patient with me. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 8, 2011 Share Posted April 8, 2011 That looks right. Are you getting the values in the $_POST array echoed to the screen looking something like this after you've filled in the form and submitted it? Array ( [PetLVL] => 100 [PeyLoyal] => 501-999 [PetEXP] => 50000 [MobLVL] => 200 [submit] => submit ) Quote Link to comment Share on other sites More sharing options...
Cyph Posted April 8, 2011 Author Share Posted April 8, 2011 Uhm no I'm not, is that a problem with my pc then I guess, gonna try on other pc see if that works, so what was/is the exact problem? Quote Link to comment Share on other sites More sharing options...
Cyph Posted April 8, 2011 Author Share Posted April 8, 2011 Ok got it now, it wasn't uploading correctly it seems. But thxs for the help. I'll let you know if I run into any more problems. Quote Link to comment 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.