Tandem Posted September 17, 2006 Share Posted September 17, 2006 I'm trying to detect whether somebodies form input, is the same as their session variable $_SESSION[username], regardless of case sensitivity.I asked somebody about this a long time ago, and they told me to use eregi, however i'm not having a slight problem with this.if $_SESSION[username] is "Tandem", and the form input is, for example, "TandemX", the eregi will still detect it.Here is a more in depth example:$_SESSION[username] is Tandem btw.[code]$blah = "TandemX";if (eregi("$_SESSION[username]", $blah)) {echo 'match';}[/code]This would echo "match". I'm not sure whether i need to use a different function altogether, or if i need to change it somehow, but i would be grateful for any help.Thanks in advance, and please point out any errors i have made. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 17, 2006 Share Posted September 17, 2006 Shouldn't you be setting $blah to Tandem instead of TandemX? If blah is TandemX and they input TandemX it is going to match because that is how you set it up.Try changing the code to this:[code]$blah = "Tandem";if (eregi("$_SESSION[username]", $blah)) {echo 'match';}[/code]Try to put in TandemX now and see if it works or not. I may be totally wrong on this, that is just what I would think. Hope it helps =) Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 17, 2006 Share Posted September 17, 2006 type redarrow in ok.[code]<?php session_start();if(isset($_POST['submit'])){$name="redarrow";$_SESSION['name']=$name;if($username==$_SESSION['name']){echo " name matched";}else{echo "no match";}} ?><form method="POST" action="test_name.php"><br>please tell me your name<br><input type="text" name="username"><br><input type="submit" name="submit" value="send">[/code] 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.