Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

need php validation *EASY* ... :)

Posted on 2007-11-30
3
Medium Priority
?
226 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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

650 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