user3486718
user3486718

Reputation: 91

PHP Pass variable through URL using ?object=value

I know there's a bunch of these topics out there, but all the answers are simply not working for me. I've tried everything I could find, and I'm still right where I started. I'm trying to pass a variable through a URL:

<a href="test2.php?one="<?php echo $_GET['one']; ?>">link</a>

When clicking on the "link", it redirects me to the appropriate page (test2.php), but leaves the value blank (resulting in localhost/test2.php?one=). This means I can no longer see what variable was being sent.

$one = $_GET['one'];
echo $one;

How can I properly send the variable from test.php to test2.php?

Upvotes: 0

Views: 354

Answers (2)

GKS
GKS

Reputation: 116

Remove quotes from the href value:

<a href="test2.php?one=<?php echo $_GET['one']; ?>">link</a>
<!--                 ^^^ - quotes missing here -->

Upvotes: 2

Youness
Youness

Reputation: 1495

you closed the href try this :

<a href="test2.php?one=<?php echo $_GET['one']; ?>">link</a>

Upvotes: 0

Related Questions