Computer problems,Computer help
*AX SOFT>>>Programming & Design

Help with PHP web form submit message?


Hi,

Just wondering if I could please get some help to modify some PHP code. The code is used to validate a web form. If there is an error in how the form is completed, an error message is generated. My problem is, how the code stands currently, if there are multiple errors in the form i.e invaild phone number and invaild e-mail address, both error messages are displayed. I would like to modify the code to only show one error message. Then once that error is corrected, the other error notification can be displayed.

Here is the current code:


if(count($errors))
{foreach($errors as $value)
{print "$value<br>";}
exit;}

if(!defined("PHP_EOL"))
{define("PHP_EOL",
strtoupper
(substr(PHP_OS,0,3) == "WIN")
? "\r\n" : "\n");}

Thanks very much,
Jo

Try:

$numoferrors = count($errors);
if ($numoferrors > 0) {
echo $errors[0];
exit;
}

Then you are just printing out the first error in the array.So once they correct that and resubmit the form the next error will be displayed. Why not use JavaScript to catch the errors before the form is submitted?

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • How to display a category menu in Drupal's front page?

    Two steps... 1) Set up your categories (make sure the Taxonomy module is enabled). 2) Set up menus that point to your category URLs. You might also consider the Taxonomy Menu add-in module...

  • How can i make personal virus...?

    First off, most viruses take some expertise to write. There is no "trivial way" to write a virus, so there are hardly any (public) tutorials available. Also note that using computer vi...

  • International Problem...?

    Not a question?

    ...
  • How many Steps to make website search engine ready?

    There are loads of things that you can do to make your site ready. SEO tutorials can be found here: ...

  • HTML: is there a book just with the list of tags names?

    There is 'HTML and XHTML Pocket Reference (Pocket Reference (O'Reilly)) (Paperback)', they are usually quite good. I have one on XML which is only about 100 pages which covers more ...

  • Poll : A new phonetic language or Transliteration of English language..?

    Transliteration of English language Unlike most other languages English doesn't have a set phonetic pronunciation for every word. Besides English,learning another 1 or 2 languages is an a...

  • Put main site in root of website?

    Putting the main site in public_html one way to do it. But assuming that your web server is an AMP, putting the main site in public_html/folder and: 1) using htaccess or 2) using a redirect PHP ...

  • When I have a form set to Post instead of Get, How do i...?

    form tag have 3 attributes 1)method 2)action 3)name suppose u r not used method attribute in form tag that time defaultly get method will be called.First u declare method as post after that u o...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster