Solved

need php validation *EASY* ... :)

Posted on 2007-11-30
3
218 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why is my $_POST not going to results page 10 67
JSON decode 5 43
php output utf-8 problem 6 50
geting data from the array list 6 36
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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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.

737 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