Reputation: 41
Please explain this code. What does "status"
and the rest of the code mean?
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks"
<?php // if status=thanks in the query string, display an thank you message instead of the form ?>
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
<p>Thanks for the email! I’ll be in touch shortly!</p>
<?php } else {
Upvotes: 0
Views: 83
Reputation: 3158
For example:
you add ?status=thanks
like
http://yourdomain.com/index.php?status=thanks
it will show the <p>Thanks for the email! I’ll be in touch shortly!</p>
if there is no status
or the status is not thanks
it will not show that comment.
Example:
create file named test.php put it in htdocs localhost
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") : ?>
<p>Thanks for the email! I’ll be in touch shortly!</p>
<?php endif; ?>
try to go to your http://localhost/test.php and http://localhost/test.php?status=thanks and http://localhost/test.php?status=you
check what will be happened?
Upvotes: 0
Reputation: 522
You need konw that:
@See-1 PHP Predefined Variables
@see-2 $_GET is An associative array of variables passed to the current script via the URL parameters.
Upvotes: 1
Reputation: 110
if you r use $_GET method in php first a follow Your URL : https://www.example.in/webhp?status=thanks.check get variable status store value of thanks.After u check in php GET method. like the following code.
<?php if($_GET['status'] == 'thanks'){?> <p>Thanks for the email! I’ll be in touch shortly!</p> <?php }else{?> <p>Error</p> <?php }?>
Upvotes: 1
Reputation: 116
The below code embedded the html and php codes, The use of below code is you can access both html tags and php values in same file.
<?php
// if status=thanks in the query string, display an thank you message instead of the form
?>
the above code, provide the php comment block, it give suggestion to developer.
<?php if (isset($_GET["status"]) AND $_GET["status"] == "thanks") { ?>
the above code used to get the value from url (using $_GET variable) (for example www.example.com/index.php?status=thanks) if the status is set in url and the value is 'thanks' means, html tag will run otherwise run the else part.
<p>Thanks for the email! I’ll be in touch shortly!</p>
else part,
<?php } else {
// do somethink..!!
}
Upvotes: 1
Reputation: 9368
Status is an variable from url which is checked for its value is set and value equals to "thanks".
Upvotes: 1