-4

I have the following very basic PHP script:

    <?php
$username = $_POST['username'];
$password = $_POST['password'];

echo "This is the username: ";
echo $username;
?>

And this is the output:

This is the username: 

I have my username and password parameters in my url. Why won't it echo the username?

2 Answers2

0

It won't display because the parameters in the URL are parsed as GET and not POST.

Use $_GET['username'] to get the data from http://www.somesite.com?username=yash

References:

Yash Kumar Verma
  • 9,427
  • 2
  • 17
  • 28
-1

Try echoing the entire $_POST array. This might lead you to the problem.

echo  "<pre>".print_r($_POST,true)."</pre>";