2

Good day,

I have a very simple script:

<?php
$first=$_POST['first'];
echo "$first";
?>

I want a the user to be able to type something into the url bar say www.test.com/test.php?first=aa;

then echo aa.

How is this possible?

1
  • Use $_GET or do you want to have both options? Commented Feb 19, 2013 at 17:59

3 Answers 3

4

Change

$first=$_POST['first'];

to

$first=$_GET['first'];

OR

$first=$_REQUEST['first'];
Sign up to request clarification or add additional context in comments.

1 Comment

It might be a good idea to read up on the PHP documentation for those variables.
2

Use GET instead of POST

$_GET["first"]

1 Comment

Additionally, you should replace echo "$first"; with echo htmlspecialchars("$first");
0

Whenever you're trying get the content of variable through your url you use:

$_GET['variable_name']

otherwise you use

$_POST['variable_name']

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.