Tandem Posted October 9, 2006 Share Posted October 9, 2006 Hi,I have a form on my site where users are supposed to input the name of another user. I want to make sure that people cannot enter their own username instead of somebody elses. It also has to be case insensitive, because with the previuos piece of code i had, people were just inputting their own username in different cases to get around it.Here's something similar to what i had before:[code]<?php$other_user = $_POST['otheruser'];if ($other_user == $_SESSION[username]) {echo "Invalid";exit();}?>[/code]I also tried a something with eregi that somebody told me would work, but that didn't work too well, and detected similar usernames as well as matches, but i deleted it and forgot the exact setup of it.Can someone suggest to me a solution?Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/23462-comparing-variables/ Share on other sites More sharing options...
michaellunsford Posted October 9, 2006 Share Posted October 9, 2006 you can convert both to lowercase for the comparision. strtolower($string);http://usphp.com/strtolower Link to comment https://forums.phpfreaks.com/topic/23462-comparing-variables/#findComment-106452 Share on other sites More sharing options...
Orio Posted October 9, 2006 Share Posted October 9, 2006 if (strtolower($other_user) == strtolower($_SESSION[username])) {die("Invalid");}Orio. Link to comment https://forums.phpfreaks.com/topic/23462-comparing-variables/#findComment-106453 Share on other sites More sharing options...
Tandem Posted October 9, 2006 Author Share Posted October 9, 2006 Wow, i didn't think of that. Thanks guys! Link to comment https://forums.phpfreaks.com/topic/23462-comparing-variables/#findComment-106454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.