Solved

need php validation *EASY* ... :)

Posted on 2007-11-30
3
214 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
Comment Utility
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
Comment Utility
Yes .. :) ... Thanks nizsmo ...

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

Expert Comment

by:nizsmo
Comment Utility
glad to help :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now