help with error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cybershot
Forum Commoner
Posts: 29
Joined: Thu Jul 24, 2008 12:06 pm

help with error

Post by cybershot »

This form works as it shows the input from the form, but I get errors on the echo of the variables. it says undefined start, payment. What is the issue here?

Code: Select all

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	<fieldset>
    	<legend>Form</legend>
		<table>
			<tr>
				<td><label for="name">Start Balance:</label></td>
				<td><label for="name">Payment:</label></td>
			</tr>
			<tr>
				<td><input type="text" id="start" name="start" /></td>
				<td><input type="text" id="payment" name="payment" /></td>
			</tr>
				<td><input type="submit" name="submit" value="submit"  /></td>
			</tr>
			
		</table>
    </fieldset>
</form>

<?php 
if(isset($_POST['submit']))
{
	
	$start = $_POST["start"];
	$payment = $_POST["payment"];
}
?>
<div id="bal">
<p><u>Balance Due</u></p><br  />
<?php 
echo $start ;
echo $payment;
?>
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: help with error

Post by Gargoyle »

both variables are only defined if $_POST['submit'] is set, which only is the case if the form was submitted.
Post Reply