0

I call my php file in the browser with "...test.php?text=Hello" but the $_POST variable stays empty (also print_r($_POST) returns array() ).

Why? Do I need to activate the post variable or something?

Thanks.

1
  • $_REQUEST['text'] also Commented Sep 2, 2013 at 14:42

3 Answers 3

2

Variables passed in through the URL end up inside $_GET, not $_POST.

$_POST contains variables parsed by reading the HTTP request body when the method is POST. In this case the method is not POST and there is also no request body.

Sign up to request clarification or add additional context in comments.

Comments

0

If you pass the variable through the URL you use $_GET. Also, you will access the variable with:

$_GET['text']

This is a array that is sent through and you need to specify what item in the array you want to use.

Comments

0

...test.php?text=hello passes data via the GET method (accessible via $_GET in the processing script).

$_POST gets populated by forms or cURL access (when the transfer method is defined as "post")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.