PDA

View Full Version : displaying form data in next page



rebecca2008
09-30-2008, 08:35 PM
Hi there,

the following code is displaying form data in a new pop up window...but how can I display form data in the next page (.html)? appreciate any help.. thanks

<html>
<head>
<title>Form Example</title>
<script LANGUAGE="JavaScript">
function display() {
DispWin = window.open('','NewWin', 'toolbar=no,status=no,width=300,height=200')
message = "<ul><li><b>NAME: </b>" + document.form1.yourname.value;
message += "<li><b>ADDRESS: </b>" + document.form1.address.value;
message += "<li><b>PHONE: </b>" + document.form1.phone.value + "</ul>";
DispWin.document.write(message);
}
</script>
</head>
<body>
<h1>Form Example</h1>
Enter the following information. When you press the Display button,
the data you entered will be displayed in a pop-up window.
<form name="form1">
<p><b>Name:</b> <input TYPE="TEXT" SIZE="20" NAME="yourname">
</p>
<p><b>Address:</b> <input TYPE="TEXT" SIZE="30" NAME="address">

</p>
<p><b>Phone: </b> <input TYPE="TEXT" SIZE="15" NAME="phone">
</p>
<p><input TYPE="BUTTON" VALUE="Display" onClick="display();"></p>
</form>
</body>
</html>

magicyte
10-01-2008, 01:30 AM
I can give you an easy example in PHP. You would need a server to do this, though:

Your first page:


<html>
<head>
<title>Form Example</title>
</head>
<body>
<h1>Form Example</h1>
Enter the following information. When you press the Display button,
the data you entered will be displayed in a pop-up window.
<form name="form1" action="submit.php" method="get">
<p><b>Name:</b> <input TYPE="TEXT" SIZE="20" NAME="yourname">
</p>
<p><b>Address:</b> <input TYPE="TEXT" SIZE="30" NAME="address">

</p>
<p><b>Phone: </b> <input TYPE="TEXT" SIZE="15" NAME="phone">
</p>
<p><input TYPE="SUBIMIT" value="Submit">
</form>
</body>
</html>

Here is the page that will load:

submit.php


<html>
<head>
<title>Form Example</title>
</head>
<body>
<ul><li><b>Name:</b> <?php echo $_GET['yourname']; ?></li>
<li><b>Address:</b> <?php echo $_GET['adress']; ?></li>
<li><b>Phone:</b> <?php echo $_GET['phone']; ?></li></ul>
</body>
</html>


Once again, you will need a server to run this PHP code. Hope I could help.

-magicyte

Twey
10-01-2008, 06:33 AM
Server-side is indeed the way you want to go — remember, not everyone has Javascript.