oliverj777 Posted August 24, 2010 Share Posted August 24, 2010 Please translate: $req_user = trim($_GET['user']); if(!$req_user || strlen($req_user) == 0 || !eregi("^([0-9a-z])+$", $req_user) || !$database->usernameTaken($req_user)){ die("Username not registered"); $req_user_info = $database->getUserInfo($req_user); Thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2010 Share Posted August 24, 2010 Sorry to be picky, but translate into what? French, German, C, Javascript, Forth, Klingon, ...? Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 24, 2010 Author Share Posted August 24, 2010 hahah - english, what is that code doing basically? Quote Link to comment Share on other sites More sharing options...
abdfahim Posted August 24, 2010 Share Posted August 24, 2010 its just checking whether the $_GET['user'] variable is 1) Set 2) have some value (not empty) 3) Alphanumeric 4) match with database username If any of the above is false, die ... Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 24, 2010 Author Share Posted August 24, 2010 Ah okay - cheers Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 24, 2010 Share Posted August 24, 2010 its just checking whether the $_GET['user'] function It's not a function is 1) Set nope - that would be isset($_GET['user']) 2) have some value (not empty) nope - that would be !empty($_GET['user']) What it actually does is strips all whitespace (spaces, tabs, linebreaks) from the beginning and the end of $_GET['user'] and then checks if there's anything left. 3) Alphanumeric correct - although using a deprecated method. preg_match or filter should be used 4) match with database username probably If any of the above is false, die ... if not call $database->getUserInfo($req_user); (probably get user info from database) Quote Link to comment Share on other sites More sharing options...
abdfahim Posted August 24, 2010 Share Posted August 24, 2010 its just checking whether the $_GET['user'] function It's not a function that was a honest typing mistake ... corrected in 2 mins, but u got me within that .. is 1) Set nope - that would be isset($_GET['user']) What do you think (!$_GET['user']) can be used for? 2) have some value (not empty) nope - that would be !empty($_GET['user']) What it actually does is strips all whitespace (spaces, tabs, linebreaks) from the beginning and the end of $_GET['user'] and then checks if there's anything left. Did I said anything much different? (except strips function, which I presumes he knows) Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 24, 2010 Share Posted August 24, 2010 is 1) Set nope - that would be isset($_GET['user']) What do you think (!$_GET['user']) can be used for? First off being set (as you first proposed) and having a value are two entirely different things. isset() is - obviously - the function to test if a variable is set. If you want to check if the string variable has a value you would use empty(). (!$_GET['user']) checks to see if the value resolves to the boolean false. That is a terrible method of testing if a variable is set and/or has a value. If the user entered the value '0' that would return false even though the variable is set and has a non-empty value. Quote Link to comment Share on other sites More sharing options...
abdfahim Posted August 24, 2010 Share Posted August 24, 2010 hmm .. point taken ... Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 24, 2010 Share Posted August 24, 2010 What do you think (!$_GET['user']) can be used for? Throwing E_NOTICEs around? Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted August 29, 2010 Share Posted August 29, 2010 Sorry to be picky, but translate into what? French, German, C, Javascript, Forth, Klingon, ...? I would like a klingon version if possible, i am about to take a trip to another stellar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.