form validation code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I've been looking at this to long, and am not seeing the issue. When i
had the below php code set to !empty instead of !isset as it is now I
got the value of the name variable echoed back, yet on sql insert that
field, along with all others are empty, though no error is generated,
just a bogus record is inserted.
When I changed to !isset I'm now getting the die statement echoed as
if no value was passed from the form. This is not the case, I filled
it out completely.
Can anyone tell me where this code went wrong?
Thanks.
Dave.

Html form:
<h3>Fields marked with a * (star) are required.</h3>
<form method="post" action="">
<div>
<label for="txtname">Name*:</label>
<input type="text" name="name" /> <br />
</div>

<div>
<input id="reset" name="reset" type="reset"/>
</div>
<div>
<input id="submit" name="submit" type="submit"/>
</div>
</form>
</div>

php Code:
// Check if fields are isset
echo "Field Checs.<br />";
if (!isset($_POST['name'])) {
echo "The value of Name is " . $_POST['name']. "<br />";
} else {
die('ERROR: Missing value - Event Name');
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux