Jump to content

HTML form and PHP


Cyph

Recommended Posts

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>

Link to comment
Share on other sites

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">

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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

)

 

Link to comment
Share on other sites

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.