Forum Moderators: coopster

Message Too Old, No Replies

passing a variable from page to page

How do I pass a variable?

         

digi_mind

1:53 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



I have two web sites. The first one allows me to enter my name an e msil address.

The second one should show me that information, but it does not do that.

The first page source code:

<form action="http://localhost/test/guest.php" method="POST">
<table border="0">
<tr>
<td>Your Name:</td>
<td><input type="text" maxlenght="12" size="20" name="user"></td>
</tr>
<tr>
<td>E mail address:</td>
<td><input type="text" maxlength="12" size="20" name="mail"></td>
</tr>
<tr>
<td><input type="submit" value="Submit details"></td>
<td><input type="reset" value="Reset the form"></td>
</tr>
</table>
</form>

The second page source code ( I name this page guest.php):

<table border="0">
<tr>
<th>Your name:
<td><?php echo $_user;?></td>
</tr>

<tr>
<th>Your e-mail address:</th>
<td><?php echo $_mail;?></td>
</tr>
</table>

The code is simple, but it doesn't work. Can anyone tell me how to get the name and email displayed in the other page?

Thanks

jetboy_70

2:06 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



Change $_user to $_POST['user'].
Change $_mail to $_POST['mail'].

digi_mind

2:33 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



Thaks. That was it.

Do you know now how I can pass a variable, but not from a form, but by clickin on any text.

Pretend I have a name that says: ABC.

I want to clik on it ans pass ABC or any other value to a page?

Thank you again.

bcolflesh

2:37 pm on Oct 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way is to pass it in the URL:

<a href="/mysecondpage.php?myvalue=ABC">ABC</a>

The other way is through the use of sessions:

us3.php.net/manual/en/ref.session.php

digi_mind

2:51 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



MMM... you may think I am stupid.

1.

I have a varible name $id
I need to add this $id to the link:

<a href ="http://localhost/web.php">Jhon</a>

now I need in stead of having web.pgp I need to have the $id. It will look something like this:

<a href ="http://localhost/0001.php">Jhon</a>.

I am really thankful.

digi_mind

2:58 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



I got it...

check this out:

echo "<a href='http://localhost/web_site/yes.php?myvalue="; echo $id ; echo "'>";

jetboy_70

3:00 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



with bcolflesh's first example you'd access your variable with $_GET['myvalue'] instead of using the $_POST array.

(got there before me!)

digi_mind

3:05 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



You are really great help... this works.

NL_Cartman

9:54 am on Oct 9, 2003 (gmt 0)

10+ Year Member



Hi,

i've asked almost the same question, you might wanna take a look at some answers i got, regarding POST & GET

[webmasterworld.com ]

Good Luck,