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
Solved

need php validation *EASY* ... :)

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

839 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