if (!isset($_POST['userName']))
printErrorMessage("Username is not filled in");
if (strlen(trim($_POST['userName'])) == 0)
printErrorMessage("Username is not filled in");
//echo $_POST['userName'];
$usernamePattern = "/^[a-zA-Z0-9]{6,18}$/";
if (!preg_match($usernamePattern, $username))
printErrorMessage("Username must contain only letters and numbers and be from 6 to 18 symbols length");
It's really frustrating that so many things that worked on wamp doesn't work in real host. I programmed my web two weeks ago and i still cannot make it work properly. Sorry for vaining, but i need help.
5 replies to this topic
#1
Posted 11 September 2011 - 09:50 AM
Hi. Once again i have to bother you with "worked in wamp, but does not work in host" problem. Let's say i type "lamato" in username field of form. Then why the code below executes function printErrorMessage("Username must contain only letters and numbers and be from 6 to 18 symbols length");
|
|
|
#2
Posted 11 September 2011 - 10:59 AM
Let's start with something simple: are you using the same version of PHP, MySQL, and Apache on both machines? If not, you could have all manner of problems. In addition, if there are different default encodings on the two systems, things can get REALLY strange.
#3
Posted 11 September 2011 - 11:19 AM
in wamp: Php 5.3.5, Mysql 5.5.8 In host: 5.3.6 php, mysql 5.5.
#4
Posted 11 September 2011 - 12:26 PM
I'd check and see if you're getting leading/trailing spaces on the username for your server.
#5
Posted 11 September 2011 - 12:36 PM
Think: Are you checking input when an error occurs? You should be double checking all input prior to calling preg_match, a vague error is likely not the issue, it is a result of a previous issue.
Try to var_dump($username) directly before calling preg_match and you will see why it fails.
Try to var_dump($username) directly before calling preg_match and you will see why it fails.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#6
Posted 12 September 2011 - 11:34 AM
Thanks for help. Had a silly mistake. Problem solved
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









