Hi so I wanted to make a little quiz in php

if(isset($_POST['City'])) {

   echo "<strong>Answer nr1:<BR></strong>";

$cities= $_REQUEST["City"];

$odp = "Madrid" || "madrid";
//$odp = "Madrid" && "madrid";
//neither of OR/AND works here 

if($cities== $odp){

	echo "Your answer is <Font Color=#009900>correct</font> <P>";

}

elseif($cities== ""){

	echo "Please fill in this form<P>";

}

else{

	echo "Your answer is <Font Color=#FF0000>false</font> <P> ";

}

}

So yeah as you can see in my code i'm trying to let the php code here count the correct answers either lowercase and not.
So I'm wondering is there anothere method for or am I doing something wrong

any help would be appreciated

thanks & regards
Katsurou

Below is a corrected version comparing case insensitive. So it will also work for MaDRiD

if(isset($_POST['City'])) {
 
   echo "<strong>Answer nr1:<BR></strong>";
 
$cities= $_REQUEST["City"];
 
$odp1 = "madrid";
//$odp = "Madrid" && "madrid";
//neither of OR/AND works here 
 
if(strtolower($cities)== $odp1){
	echo "Your answer is <Font Color=#009900>correct</font> <P>";
    } elseif($cities== ""){
	echo "Please fill in this form<P>";
    } else{
	echo "Your answer is <Font Color=#FF0000>false</font> <P> ";
    }
 
}
#
$odp = "Madrid" || "madrid";
if($cities== $odp)
{

This will result to something like this

if($cities== "Madrid" || "madrid")

this is a wrong statement....
it should come like this format

if( ($cities == "Madrid") || ($cities == "madrid"))

Thanks guys that helped me out alot =)
however I've stumbled on the next problem when I'm trying to see my answer with this lines of command

include ('test.php');


echo "<Font Color=#0000FF> <h1> Correct answers:</h1><p></font>";
echo "<h2>Answer nr1. <Font Color=#009900>$odp</h2><P></font>";

then I get to see "1"....
So my question is:
Can I solve it with another line of code or should I just write it down on echo?

thanks & regards
Katsurou

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.