Jump to content

If Statement & POST problems


Bopo

Recommended Posts

Hi

 

Basically I have a username and password form therefore assume two textboxes and a button, I have written several if statements for validation purposes, however even when I know validation has been passed, the messages still appear.

 

<?php 

if(isset($_POST['submit'])) {


$message="";  // this will hold the error msg

$username = ($_POST['username']);
$password = ($_POST['password']);


if(strlen($username < 5)) {
					 $message = "Your username must be over 5 characters long";
					 echo "$message";
					 exit();
	  }

if(strlen($password < 5)) {
					 $message= "Your password must be over 5 characters long";
					  echo "$message";
					 exit();
	  }
	  
// regular expression to ensure only upercase & lowercase characters are used

if(ereg('[^A-Za-z0-9]', $username))
$message = "Please user uppercase & lowercase a to z characters";
echo "$message";
exit();
}
?>

 

Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/150188-if-statement-post-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.