Page 1 of 1
[SOLVED] back for more help - case insensitivity
Posted: Wed Aug 04, 2004 12:42 pm
by Daisy Cutter
I wont give the exact code I'm using as it's pretty big, but here's the part I need to do:
I have a form submit text to index.php, which will echo either $_POST["foo"] is correct, if it is BAR, or any case (bar BaR bAR, etc.)
otherwise it will echo $_POST["foo"] is incorrect.
Code: Select all
if (strpos($_POST["foo"], 'bar') !== FALSE) {
echo """;
echo $_POST["foo"];
echo "" is correct."; }
if you want to see the page it's at
http://metawire.org/~mcovey
?>
Posted: Wed Aug 04, 2004 2:29 pm
by xjake88x
I don't know what you mean but if you want case insensitivity on say.. a username/pw do this:
Code: Select all
$user=$_POST['user'];
$pass=$_POST['pass'];
$result=mysql_query("SELECT * from my_users where user='$user'") or die(mysql_error());
$r=mysql_fetch_array($result);
$real_user=$r["user"];
$real_pass=$r["pass"];
if(trim($real_user)!=""){
if(strtolower($real_user)==strtolower($user) && strtolower($real_pass)==strtolower($pass)){
//The login is good!
}
}
Posted: Wed Aug 04, 2004 3:15 pm
by Daisy Cutter
THANK YOU!!
I had to make it:
Code: Select all
<?php
if (strpos($_SERVER['HTTP_REFERER'], 'test.php') !== FALSE) {
if ($_POST["foo"]) {
--> new line: strtolower($_POST["foo"])==strtolower('bar')) {
--> commented out old line // if (strpos($_POST["foo"], 'bar') !== FALSE) {
echo """;
echo $_POST["foo"];
echo "" is correct."; }
else {
echo """;
echo $_POST["foo"];
echo "" is incorrect.";}
}
elseif ($_POST["name"]) {
if (strpos($_POST["name"], 'matt') !== FALSE) {
echo "welcome, ";
echo $_POST["name"]; }
else {
echo "you aren't welcome here, ";
echo $_POST["name"];
echo ". </h1>just kidding. <h1>"; }
}
}
else { }
?>
My ultimate goal is to write a minimal forum system like phpBB, using PunBB as my inspiration, its a minimal forum too.