Storing the value of a textbox
Posted: Fri Apr 27, 2007 8:33 am
Jcart | Please use
page2
Unfortunately, the opening page is blank...I don't know what to do...please, help me
Jcart | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I have a form with a textbox and A submit button. I want the value of the textbox to be stored in a variable so as to pass through to other pages.
I have reached this point:
page 1Code: Select all
<?php
session_start();
if (isset($_POST['txtusername']))
$_SESSION['test'] = $_POST['txtusername'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="page2.php">
<input type="submit" name="Submit" value="Submit" /></a>
<input type="text" name="txtusername" />
</form>
</body>
</html>Code: Select all
<?php
session_start();
echo $_SESSION['test'];
?>
<?php echo $_SESSION['test']; ?>Jcart | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]