Jump to content

eregi...


Tandem

Recommended Posts

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.
Link to comment
Share on other sites

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 =)
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.