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

Button start new page and send value(s) to this page

Status
Not open for further replies.

michelleqw

Programmer
Joined
Jan 4, 2004
Messages
120
Location
DE
Dear users,

Is it possible to send with the help of a button a value to an other page with method 'get' or 'post'? Can you pls send us a source code?

Nice regards,

Michelle.
 
Form:

Code:
<form action="file.php" method="post">
<input type="hidden" name="valuename" value="actualvalueyouwanttopass">
<input type="submit" name="submit" value="submit">
</form>

Code on page.php

Code:
if(isset($_POST['submit'])) {
$actualvalue = $_POST['valuename'];
echo $actualvalue;
}

If you want the user to enter a value, then replace:

Code:
<input type="hidden" name="valuename" value="actualvalue">
Code:
<input type="test" name="valuename">

Have not tested it but that should work.

Dan

Dan Morgan -
 
Hrllo DannyTEM,

Thanks for the information. My problem at the moment is that I want to send an integer or a string value via a button to a new page. We don't want to use the input object!
Maybe you can generate a source code for this?

Michelle.
 
Well in that case you use the input type=hidden method shown above. This will just show a single button with no showing input boxes.

If you want to put in the value dymanically, store the value in a variable and then:

Code:
<input type="hidden" name="valuename" value="<?php echo $value; ?>">

Unless when you say 'button' you mean a graphical button which is hyperlinked?

Code:
<a href="[URL unfurl="true"]www.domain.com/page.php?id=somevalue"><img[/URL] src="[URL unfurl="true"]www.domain.com/images/image.gif"[/URL] border="0" /></a>

Replace somevalue with the string or integer you want to pass then use;

Code:
if(isset($_GET['id'])) {
$actualvalue = $_GET['id'];
echo $id;
}

Dan Morgan -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top