check field input php help?

hjfxghd7

New member
I making a form with the following fields:


Character Name

Race

Class

Level

Primary Profession

Secondary Profession

Email

Password

Retype Password


I want to check to see if fields are empty, if password is shorter that 6 char, password/retype password are equal, lvl less than or equal 85, and email is valid
 
Check out the comparison operators at PHP
http://www.php.net/manual/en/language.operators.comparison.php

Check for empty fields with isset()
http://www.php.net/manual/en/function.isset.php and http://php.net/manual/en/function.empty.php

Also, to check for the length of input, you can use the strlen() function:
http://www.php.net/manual/en/function.strlen.php


Everything else should be straightforward.


I would also suggest you set up these checks on the client side using JavaScript to prevent unnecessarily polling your server side PHP code.
 
To check if fields are empty use if (!$_POST["fieldname"]) { die("somemessage"); }
For password if($_POST["firstpassword"]!=$_POST["secondpassword"]) { die("somemessage"); } replace POST with GET if you use that method. Be sure to encode password and escape all user inputs.
 
Back
Top