moath qutoob
moath qutoob

Reputation: 41

I cant understand this code of php $_GET

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&rsquo;ll be in touch shortly!</p>
        <?php } else { 

Upvotes: 0

Views: 83

Answers (5)

Josua M C
Josua M C

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&rsquo;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&rsquo;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

Lomesh Kelwadkar
Lomesh Kelwadkar

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&rsquo;ll be in touch shortly!</p>
<?php }else{?>
 <p>Error</p>
<?php }?>

Upvotes: 1

sathish kumar
sathish kumar

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&rsquo;ll be in touch shortly!</p>

else part,

<?php } else { 
// do somethink..!!
}

Upvotes: 1

Insane Skull
Insane Skull

Reputation: 9368

Status is an variable from url which is checked for its value is set and value equals to "thanks".

Upvotes: 1

Related Questions