Solved

need php validation *EASY* ... :)

Posted on 2007-11-30
3
215 Views
Last Modified: 2008-03-04
Hi.
I believe this is an easy task for you (but not for me) ... Below are 'working codes' and I want to add/insert PHP validation so MINIMAL PASSWORD entered is 5 digits; if less then it should display error message.

Please modify below codes ... Thanks.
if (isset($_POST['submit'])) {
$report = array(); 
if (empty($email)) {
 $report[] = "Please enter your email address and password!";
 }
  elseif (!empty($email) && (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email))) {
  $report[] = "Please enter a valid email address e.g. email@domain.com";
  }
   elseif (empty($password)) {
   $report[] = "Please enter your password!";
   }
} // End if all

Open in new window

0
Comment
Question by:planetemails
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
nizsmo earned 100 total points
ID: 20387318
Something like this?
	if (isset($_POST['submit'])) {
$report = array(); 
if (empty($email)) {
 $report[] = "Please enter your email address and password!";
 }
  elseif (!empty($email) && (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email))) {
  $report[] = "Please enter a valid email address e.g. email@domain.com";
  }
   elseif (empty($password) || strlen($password)<5) {
   $report[] = "Please enter your password!";
   }
}

Open in new window

0
 

Author Comment

by:planetemails
ID: 20387336
Yes .. :) ... Thanks nizsmo ...

strlen ... I always think something like value<5
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20387340
glad to help :)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question