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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie ?: Form variables aren't passing?

Status
Not open for further replies.
Jan 23, 2002
63
US
Duhhhhhh...can you help someone trying to learn PHP?

I've got an HTML page:

<html>
<head>
<title>Test Form</title>
</head>
<body>
<form method="get" action="formresult.php">
Enter the stuff:
<input name="mytext1" type="text">
<input type="submit">
</form>
</body>
</html>

Feeding a php page:
<html>
<head>
<title>Form Result</title>
</head>
<body>
<?php
echo $mytext1;
?>
</body>
</html>

When I run it, I get:
Notice: Undefined variable: mytext1 in c:\inetpub\ on line 7

PHP is running, but for some reason the php page is not taking in the form variable??? GET and POST get the same results.

Thanks!
- Nowandever29
 
hi,

try replacing $mytext1 with $HTTP_GET_VARS['mytext1'] or $_GET['mytext1']

and see what happens

Parth
 
The way you did it origianlly used to be the way it was done, in fact it was a selling point for PHP, all variables were always available.
The problem is you don't really know what your script is recieving e.g. I could send a url which would create a varialbe $badman which I know nothign about, even worse if you had a varialbe in your scriot called $badman I've just trampled on it (probabbly !)
 
also when you echo $_GET['mytext1']; add quotes or strange thngs will happen if theres spaces in the text you entered .

e.g.

echo "$_GET['mytext1']";

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top