Re: form validation code
| From: | Daniel P. Brown | Date: | Wed, 30 Jun 2010 13:23:25 +0000 |
| Subject: | Re: form validation code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306562@lists.php.net to get a copy of this message | ||
On Wed, Jun 30, 2010 at 09:07, David Mehler <dave.mehler@gmail.com> wrote:
> 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?
Sure.
> php Code:
> // Check if fields are isset
> echo "Field Checs.<br />";
> if (!isset($_POST['name'])) {
.... the line above.
(Hint: isset != empty)
(Another hint: with !empty(), you told PHP, "if it's not empty."
Now, with !isset(), you're saying, "if it's not set.")
(Answer: Remove the exclamation point from !isset().)
--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/