Jump to content


Photo

eregi...


  • Please log in to reply
2 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 17 September 2006 - 03:07 PM

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.
$blah = "TandemX";

if (eregi("$_SESSION[username]", $blah)) {
echo 'match';
}
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.

#2 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 17 September 2006 - 03:39 PM

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:

$blah = "Tandem";

if (eregi("$_SESSION[username]", $blah)) {
echo 'match';
}

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 =)

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 September 2006 - 04:00 PM

type redarrow in ok.

<?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">

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users