PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Daisy Cutter
Forum Commoner
Posts: 75 Joined: Sun Aug 01, 2004 9:51 am
Post
by Daisy Cutter » Wed Aug 04, 2004 12:42 pm
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
?>
xjake88x
Forum Commoner
Posts: 50 Joined: Sun Aug 01, 2004 7:05 pm
Post
by xjake88x » Wed Aug 04, 2004 2:29 pm
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!
}
}
Daisy Cutter
Forum Commoner
Posts: 75 Joined: Sun Aug 01, 2004 9:51 am
Post
by Daisy Cutter » Wed Aug 04, 2004 3:15 pm
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.