How to make sure username and password is case sensitive.

I have a validation php script that checks the registration form. I want it to make sure it checks the username and password is case sensitive.
//validate fields
	if(!$_POST["username"] || !$_POST["email"] || !$_POST["password1"] || !$_POST["password2"]){
		echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />Please fill the required fields, <p>&nbsp;</p><p>&nbsp;</p><a href='register.php'>Go to register page</a>";
	
	//validate password
	}else if($_POST["password1"] != $_POST["password2"]){
		echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />Please go back, PASSWORDS do not match! <p>&nbsp;</p><p>&nbsp;</p><a href='register.php'>Go to register page</a>";
	
	//validate password length
	}else if(strlen($_POST["password1"]) < 6){
		echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />Please go back, PASSWORD is too short! <p>&nbsp;</p><p>&nbsp;</p><a href='register.php'>Go to register page</a>";	
		
	//validate username length
	}else if(strlen($_POST["username"]) < 5){
		echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />Please go back, USERNAME is too short! MUST BE BETWEEN 5 to 10 characters.<p>&nbsp;</p><p>&nbsp;</p><a href='register.php'>Go to register page</a>";	
		
	//validate email	
	}else if(!(eregi("^.+@.+\\..+$", $_POST['email']))){	
		echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />Please enter a valid EMAIL! <a href='register.php'><p>&nbsp;</p><p>&nbsp;</p>Go to register page</a>";
	
	//validate captcha
	}else if(($_SESSION['security_code'] != $_POST['security_code']) || (empty($_SESSION['security_code'])) ){
		echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />CAPTCHA CODE does not match! <p>&nbsp;</p><p>&nbsp;</p><a href='register.php'>Go to register page</a>";
	
	}else{
		$conn=  mysql_connect($servername,$username,$password)or die(mysql_error());
		mysql_select_db("",$conn);
		
		// check if already registered
		$sql_check = "SELECT * FROM users WHERE email = '".$_POST[email]."'";
		$result_check = mysql_query($sql_check,$conn) or die(mysql_error());		
		$row = mysql_fetch_assoc($result_check);
		if($row['id']){
			echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br />EMAIL already registered! <p>&nbsp;</p><p>&nbsp;</p><a href='register.php'>Go to register page</a>";

Open in new window

genesisvhAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lukasz ChmielewskiCommented:
If you calculate hash value (like md5 or sha1) for the password and store it in the database like this, it IS case sensitive, md5("somepassword") <> md5(Somepassword). If this is what you mean... Or you want to check if there are big and small letters ?
wuyinzhiCommented:
your code already case sensitive i think, though i think usually password is case sensitive but username is case insensitive. in case you want to make it case insensitive, use function strtoupper to compare them.
Mohamed AbowardaSoftware EngineerCommented:
Check here:
http://www.abstraction.net/ViewArticle.aspx?articleID=72

Another solution, you can execute normal SQL query to check if the credentials is valid and if valid, get the username from the database using mysql_fetch_array() and compare the two usernames variable (the one that was used by the member to login and the one in the database) to check if the username is in the correct case, you should also use MD5 with the password, that way the password will be case-sensitive since MD5 encryption is case-sensitive.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mpickreignCommented:
If you are just looking to make sure they cased it the same in a password box and a confirm password box you can use strcmp()

http://www.php.net/manual/en/function.strcmp.php
genesisvhAuthor Commented:
Yup You got it
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.