dose Posted November 4, 2009 Share Posted November 4, 2009 ok so i have a gamer card script going with help from a few friends, and we noticed a user putting in random junk.. main code is excluded but this is how we are grabbing the user name. my question is how could we make the script stop executing if $user = a certain name? if(!empty($_GET['user'])) { // cache $user = str_replace(" ", "", strtolower($_GET['user'])); // remove spaces and lower } ive tried to use if($user = "kipu") { exit; } but when i do that it stops working for every name.. Link to comment https://forums.phpfreaks.com/topic/180280-solved-need-help-blocking-user/ Share on other sites More sharing options...
dgoosens Posted November 4, 2009 Share Posted November 4, 2009 if($user = "kipu") { exit; } that's because you only used one = sign and thus assign "kipu" to $user Link to comment https://forums.phpfreaks.com/topic/180280-solved-need-help-blocking-user/#findComment-951006 Share on other sites More sharing options...
Bricktop Posted November 4, 2009 Share Posted November 4, 2009 Hi dose, Using the following will work: if(!empty($_GET['user'])) { if($_GET['user']=='kipu') { exit(); } else { // cache $user = str_replace(" ", "", strtolower($_GET['user'])); // remove spaces and lower } } Or, you could do it using: if(!empty($_GET['user'])) { // cache $user = str_replace(" ", "", strtolower($_GET['user'])); // remove spaces and lower if($user=='kipu') { exit(); } } The first method performs the check on the username as it is fetched using the $_GET command, the second method performs the check once the username has been fetched and has been stored into the $user variable. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/180280-solved-need-help-blocking-user/#findComment-951009 Share on other sites More sharing options...
dose Posted November 5, 2009 Author Share Posted November 5, 2009 k ill give it a try later what i get home Link to comment https://forums.phpfreaks.com/topic/180280-solved-need-help-blocking-user/#findComment-951406 Share on other sites More sharing options...
dose Posted November 5, 2009 Author Share Posted November 5, 2009 if($_GET['user'] == "kipu") { exit(); } worked thanks much.. tried the other way with $user instead of the get and it wasnt working for whatever reason. Link to comment https://forums.phpfreaks.com/topic/180280-solved-need-help-blocking-user/#findComment-951474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.