PDA

View Full Version : PHP Form Help


threat
03-12-2010, 09:33 PM
If you know how to work with forms in PHP I need someone to tell me what I have wrong in my code. I am getting an error on two lines where I trim the input from both staring and stopping form.


else if($_SERVER["REQUEST_METHOD"] == "POST"){
//the page got here from submitting the form, let's try to process
$starter = trim($_POST["starting"]);
$stoper = trim($_POST["stopping"]);
$incr = trim($_POST["increment"]);



This is my bit where I create the forms, it is one of the last bits of code at the bottom.


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
Starting Temperature: <input type="text" name="starting" value="<?php echo $starter; ?>" size="5" />
</form><br/>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
Stop Temperature: <input type="text" name="stopping" value="<?php echo $stoper; ?>" size="5" />
</form><br/>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
Temperature Increment: <input type="text" name="increment" value="<?php echo $incr; ?>" size="5" />
<br/><input type="submit" value="Create Temperature Conversion Table" />
</form><br/>


So whenever I access the page in the post method, I get these two errors.

Notice: Undefined index: starting in D:\My Documents\Winter2010\intin\chan kameron\lab6Chan.php on line 30

Notice: Undefined index: stopping in D:\My Documents\Winter2010\intin\chan kameron\lab6Chan.php on line 31

BaconPie
03-12-2010, 09:46 PM
Did you close the 'else if' with a }?

threat
03-12-2010, 09:48 PM
I found it. Yeah I have it closed. The problem was with the multiple <form> tags. I combined them all into one and it seems to work properly now.