?
Solved

need php validation *EASY* ... :)

Posted on 2007-11-30
3
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
nizsmo earned 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

770 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