0

I'm totally new to PHP, and have no idea how to get this simple function straight. I want to retrieve the parameter from the url, testsite.com?name=chris, and then use the parameter to drive an IF...THEN statement,

if ($_GET['name'] = "chris") {
    echo "Have a good day! ". $_GET['name'];
} else {
    echo "Have a good night unknown!";
}

I just get Have a good day! Chris no matter what I do, even if I change the name parameter in the URL.

1 Answers1

0

You wrong to use simbol :

if ($_GET['name'] == "chris") {
    echo "Have a good day! ". $_GET['name'];
} else {
    echo "Have a good night unknown!";
}

$x=1;  //$x is 1 
$x=='1' // is if $x is equal to 1
Simone Rossaini
  • 8,115
  • 1
  • 13
  • 34