Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

working with get variables I thought thanks does not matter if i put Thanks

I thought "thanks" does matter if i put "Thanks". it goes to else block. because Thanks which is true it will tell you the paragraph but its not. strange? why?

<?php if (isset($_GET["status"]) AND $_GET["status"] == "Thanks") { ?> <p>Thanks for the email! I’ll be in touch shortly!</p> <?php } else { ?>

Our code checks if the status variable has a value of thanks, it outputs this thank you message

3 Answers

Hi Brian,

I'm not sure if I understood your question right but the check you are performing for status is case-sensitive. Are you sure that when you set the GET variable "status" that it is with capital T?

 $_GET["status"] == "Thanks"

is not the same as

 $_GET["status"] == "thanks"

If you just want to compare that the strings are same regardless if they are upper- or lowercase you can use strtolower() -function. It converts all characters in a string to lower case. Then you would write something like this:

<?php
if (isset($_GET["status"]) AND strtolower($_GET["status"]) == "thanks") {
  echo "Thanks for the email! I'll be in touch shortly!";
} else {

}
?>

Notice also that I used "echo" to display the text so the code is just a bit more pleasurable to read. :)

Hope this helps!

Br Tuomo

Try to use "===" in your if stamment

I did not realized the "thanks" value is the case sensitive. The "===" is very strictly of case sensitive it must be match compare of case sensitive but its same as ==. I was searching in my code there were three found thanks words in there and i decided to change the https header("Location: talktous.php?status=Thanks"); exit; } ?>
it does making sense condition is true output the echo not else block thanks!