Jump to content

ctype_space submission form error handling


tribol

Recommended Posts

Hey all, quick question here. I've created a form and people seem to think that they can submit they're nickname with spaces in it. I've posted the snippet of code below and my edit for the ctype_space is on line 3. My question is will it parse knowing that I'm talking about the nickname since the last line was $check_nickname? or am i missing something...

btw $check_nickname is a function passed to mysql and in this case the trim() function won't work since it only checks for spaces in the prefix and suffix.

[win] means the nickname has been checked against the database and is good to go.

Help? (sorry if i worded it confusingly)

 

	
if ($check_email) $errors.="- Someone has already registered using that email address<br />";
if ($_POST['win']=="yes" && $check_nickname) $errors.="- Someone has already taken that nickname. Please choose another<br />";
if ($_POST['win']=="yes" && $ctype_space) $errors.="- You cannot use spaces in your nickname. Please try again.<br />"; //to use for checking spaces in nickname
if (!$_POST['firstName']) $errors.="- Your first name is required<br />";
if (!$_POST['lastName']) $errors.="- Your last name is required<br />";
if ($_POST['win']=="yes" && !$_POST['nickname']) $errors.="- Your nickname is required<br />";
if (!$_POST['email']) $errors.="- Your email is required<br />";
if (!$_POST['password']) $errors.="- Please senter a password<br />";
if (!$_POST['retype']) $errors.="- Please retype your password<br />";
if ($_POST['password'] && $_POST['retype'] && $_POST['password']!=$_POST['retype']) $errors.="- The passwords you typed do not match<br />";

 

thx

tribol

I understand what you're saying but i'm just maintaining this site, it was built by someone else.

 

I'm getting closer, boiled it down to:

 

if (!$ctype_space['nickname']) $errors.="- You cannot use spaces in your nickname. Please try again.<br />";

 

Except when i do it this way it brings up the error no matter what, if I remove the ! at the beginning of the statement it doesn't work at all.

Ok, will someone please explain to me why this isn't working???

 

if (ctype_space($_POST['nickname'])==true) $errors.="- You cannot use spaces in your nickname. Please try again.<br />";
//to use for checking spaces in nickname

 

I've got everything right so far as I can tell, i've gone over it again and again... but for some reason it's not doing anything! grrr..

I don't believe I didn't pick that up from all the reading i've been doing about it for the last couple days but yeah that's right. I figured it out using

 

strstr($_POST['nickname']," ")==true

 

to check if there were any spaces and returned an error message if there were.

thx

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.