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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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! 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.