faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 17 people (47%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can i display query string values into my form? (ie. ) www.uniware.net/mypage.php?msg=value

Mar 5th, 2002 21:25
Nick R, Ram Kathir,


<html>
<head>
<title>the page that passes the string</title>
</head>
<body>
<?php
//say your string is $my_string 
$my_string="passing values to forms";
// sends the string in a hyperlink (query string)
echo "<a href='your_form_page.php?my_string=$my_string'>send the 
string</a>";
?>
</body></html>
<!------------------Your next page is as follows------------------------
-->
<html>
<?php 
//create the global variable $my_string or you may get a warning
global $my_string; 
?>
<head>
<title>the page that the form is on, receiving the string</title>
</head>
<body>
<form name="whatever" action="validate.php">
<!--echo the $my_string variable in the value=""(comes from previous 
page string query------>
<input type="text" name="the_string" value="<?php echo $my_string; ?>">
<input type="submit" value="submit">
</form>
</body></html>