Jump to content

Archived

This topic is now archived and is closed to further replies.

Tandem

eregi...

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.

Share this post


Link to post
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 =)

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.