Closed Thread Icon

Topic awaiting preservation: Passing variables from a form to another html page Pages that link to <a href="https://ozoneasylum.com/backlink?for=26745" title="Pages that link to Topic awaiting preservation: Passing variables from a form to another html page" rel="nofollow" >Topic awaiting preservation: Passing variables from a form to another html page\

 
Author Thread
Hustluz
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 09-29-2005 06:21

I am trying to pass variables submitted by form onto another html page where i can echo it out just to see if it is working. the trouble is when i echo it out on the next page i get nothing. it seems liket he variables isnt storing. my code is:

1st page:

<body>
<Form action="resultsbyname.php" method="post">
Please enter the name, or part of the name, of the shop you are seeking:
<br />
<input name="name" type="text" />
<br />
<input type="submit" value="search">
</Form>
</body>

2nd page:

<?
echo $name;
?>

as you can see im trying to use the form to pass the variable name and store it to the next page where i can echo it out as a php variable value that was input into the form on the page before. for some reason the variable is getting lost. any suggestions?

Veneficuz
Paranoid (IV) Inmate

From: A graveyard of dreams
Insane since: Mar 2001

posted posted 09-29-2005 12:17

To access the variable on the second page you need to use $_POST['name'], instead of just $name.

_________________________
"There are 10 kinds of people; those who know binary, those who don't and those who start counting at zero"
- the Golden Ratio - Vim Tutorial -

Hustluz
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 09-29-2005 17:04

thanks for the help but i also figured out what the problem was. if any one is intrested i had to Check the php.ini file and see if register_globals = On that fixed the problem. thanx Veneficuz for your help as well

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 09-29-2005 17:10

Don't do that!

Turn that back to off and use Veneficuz's method. It is a bit more secure.

Dan @ Code Town

Hustluz
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 09-30-2005 00:50

okay yea i was thinking the same things but im just doing it for the purpose of this tutorial i will change it back...thank you

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 09-30-2005 14:30

From my blog:

Passing FORM variables among pages

Hustluz
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 10-05-2005 17:05

i looked at the page (above) but what would i do with the hidden inputs how does that help me pass things from one page to another. and what is the advantages of doing it this way

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 10-05-2005 17:44

Hidden inputs are merely inputs that are... hidden . Its often useful to use them for things, they are treated like any other input when retreiving the data.

All he is doing in that tutorial is passing the values that someone submitted in a form, to the next page and setting them as hidden values so that they can then be passed onto yet another page. You dont always have to do this sometimes your form results will be handles as soon as you press submit so you wouldnt have to create the extra input hidden items.

« BackwardsOnwards »

Show Forum Drop Down Menu