FAQ: HTML Form Handling in PHP - Request Superglobals

This community-built FAQ covers the “Request Superglobals” exercise from the lesson “HTML Form Handling in PHP”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn PHP

FAQs on the exercise Request Superglobals

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Bug in PHP - Request Superglobals

There seems to be an issue with the first instruction in HTML Form Handling in PHP - Request Superglobals. I am using print_r($var) to print the following superglobals:

  • $_REQUEST
  • $_GET
  • $_POST

I am passing in the above superglobals as arguments for print_r() in the designated spaces with the PHP tag, but it keeps asking if I used print_r() to print the $_REQUEST array. Maybe I am doing it wrong, but I can’t figure out any other possible solutions.

Hey there,

What does your code look like? Just to make sure :slight_smile:

So I had the same issue you did. I messed around for a while with no success, then I thought it might be possible that the PHP statement needed to be made all on the one line, (like the example below). That worked.

<?php print_r($var) ?>

I’m posting this for anyone in the future who gets stuck on this.

2 Likes

I’m guessing that you probably forgot a semicolon at the end of statement. It was like that in my case

Yes seems like it. It doesn’t work for me too until I have to remove the comment and write the php statement in one line for each. No idea why does it have to be this way.

I had this same error, all my code was correct, but when comparing my code with the solution, the side with my code was still displaying “#Print REQUEST data here” instead of what i’d written.

Refreshed the page a few times and pasted the same code back in and it worked after a couple of tries

For some reason, this one works only if you also remove the comments. Please add that to the instructions.

Even when it may not be required, one is still best to stick to the rule… Never leave out semi-colons.

    $_REQUEST:
    <?php print_r($_REQUEST); ?>
    <br>
    $_GET:
    <?php print_r($_GET); ?>
    <br>
    $_POST:
    <?php print_r($_POST); ?>

Was there a previous lesson where print_r was covered? I feel like I might have skipped over something. I just completed the intro course and started in on this one. It was not clear what I was supposed to do until I came here and saw the answer.

You have to remove the comment for the code to work.