Jump to content

Recommended Posts

when  a form says the username can contain only for example letters and numbers , how do it check the username ?

for example if i use uername  abc-123  ,  how can i find out i have used "-" in my username ?

my english bad , i don't want to define all the "not-allowed" characters to find out, i want the backward thing, just check the allows characters, otherwise --> error .

 

Link to comment
https://forums.phpfreaks.com/topic/78659-username/
Share on other sites

really thanks , could please tell me what        /^[a-zA-Z0-9\_\.]+$/        means ?

 

as i know preg match will ask , what are you looking for , and where are looking for ,

in what part,  i only understood the a-zA-Z0-9.  but  what those  / ,  ^ , \_\ ,  .    +$    means ??

 

Link to comment
https://forums.phpfreaks.com/topic/78659-username/#findComment-398019
Share on other sites

I like to do it in Javascript

 

html input field

<input name=testfield value="hello-there" onblur="removeInvalidChars(this);">

 

Javascript code

function removeInvalidChars(inputObj)
{
	var regSpaces = new RegExp(/([-!@#$%])/g);
	if (regSpaces.test(inputObj.value)) {
		alert('Invalid Characters entered');
		var objval = inputObj.value.replace(/([-!@#$%])/g,'');
		inputObj.value = objval;
	}
}

 

this code also removes the offending chars

Link to comment
https://forums.phpfreaks.com/topic/78659-username/#findComment-398021
Share on other sites

it is too simple

wen somebody fill the form user and password :

script do this :

 

insert into tableuser values ($_POST[username],$_POST[password]);

 

then in login page,

i have

select * from tableuser where username='$_POST[username]' and password='$_POST[password]'";

.

.

.

i have a test user name "john" , with password "qwerty",

i can log in with this user and password , no problem

but when i type the password "QWERTY" , it won't sign in , cos uppercase and lowercase matters to password.

then again if i type the user "JOHN" and password "qwerty" , it works and sign in , cos uppercase and lowercase letters do not matter to user name ,

i want to know how can makes it matter to username ? like password, uppercase nad lowercase matters.

example :

john  qwerty sign in

JOHN  qwerty won't sign in,

 

Link to comment
https://forums.phpfreaks.com/topic/78659-username/#findComment-398046
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.