Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MIssing variable

Status
Not open for further replies.

TheMaskedPencil

Programmer
Jan 18, 2005
6
CA
I a trying to send variable using a GET method, but it isn't showing anything (before it was showing an Undefined Variable error, but I turned the error notices). My question is, how do I pass the variable from one page to the other.

Here is the code for Text.html

<html>
<body>
<form action="text.php" method="get">
Who is your favorite author? <input name="author" type="text"><br><br>

<input type=submit>
</form>

</body>
</html>

And here is the code for the text.php page.

<html>
<body>
Your favorite author is <?php echo $author; ?>
</body>
</html>

I have tried using a $_GET['$author'] and $HTTP_GET['$author'] and still nothing.

I have been looking through all the forums to try and get the answer, but I still cannot get a thing. Any help would be much appreciated.

 
You have a superflous $ in your $_GET reference:
Code:
$_GET['[b][red]$[/red][/b]author'];
Remove that $ and you should be set.

Incidentally, in old PHP versions (pre 4.1.0), the global array that stored all the values from URL was $HTTP_GET_VARS not $HTTP_GET.
 
Thanks for the help. I was just going by what the code tips were so I had to guess.
 
I have some suggestions to your code:

Code:
<html>
<head>
  <title>foo</title>
</head>
<body>
<form action="text.php" method="get">
Who is your favorite author?&nbsp;&nbsp;<input name="author" type="text" value="" />
<p>
  <input type="submit" value="Submit" name="submit" />
</p>
</form>

</body>
</html>

/* And here is the code for the text.php page. */

<html>
<head>
  <title>bar</title>
</head>
<body>
Your favorite author is <?=$_GET['author']?>
</body>
</html>

ps. it might be full of typo's, as I'm pretty darn sick today :p I feel like crap, and so does my mind.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top