Jump to content

Archived

This topic is now archived and is closed to further replies.

hanlonj

Form Validation Bug

Recommended Posts

Hi,

I am validating a form on a page using the [code]$_SERVER[PHP_SELF}[/code]superglobal.

I check for empty fields and display an error beside the field that is empty so the user will know what to correct (as per usual on a website).My problem is that when the page loads initially, the form is as you would expect empty. so the errors appear upon first loading of the page.

I realise this is easy to fix but the solution is escaping me at the moment.

Can anyone help?

John

Share this post


Link to post
Share on other sites
that means, you are probably running your validation without ever seeing whether or not the form has been submitted. let's say you have your submit button simply named "submit", you'll need to wrap your entire validation and processing within something like this:
[code]
<?php
if (isset($_POST['submit'])) {
  // process your form here.
}
?>
[/code]

Share this post


Link to post
Share on other sites
[quote author=obsidian link=topic=108839.msg438297#msg438297 date=1158784082]
that means, you are probably running your validation without ever seeing whether or not the form has been submitted. let's say you have your submit button simply named "submit", you'll need to wrap your entire validation and processing within something like this:
[code]
<?php
if (isset($_POST['submit'])) {
  // process your form here.
}
?>
[/code]
[/quote]

Excellent, worked no problem.

Thank  you very much.

John

Share this post


Link to post
Share on other sites

×

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.