Welcome to WebmasterWorld Guest from 54.242.193.41

Forum Moderators: open

Message Too Old, No Replies

Passing Data Between Pages

Pass data from form to another page - cookie

     
7:44 pm on Jul 28, 2005 (gmt 0)

New User

10+ Year Member

joined:June 21, 2003
posts:32
votes: 0


Excuse my lack of knowledge on JS!

Can this be done using cookies & JS only?

I need to do the following:

1. User lands on index.htm - Enters name & some details into a form.

2. User submits form and goes onto nextPage.htm (redirect using FormMail.cgi).

3. When they are on nextPage.htm I need to then write the details they entered in the form on the index page to this page.

Can I do this using cookies? If so does anyone know of some example code for both pages anywhere?

If not what about php or cgi (I have no knowledge of either). Examples anywhere?

Many, many thanks in advance
Chris

11:21 pm on July 28, 2005 (gmt 0)

New User

10+ Year Member

joined:June 21, 2003
posts:32
votes: 0


Okay sorry found the below:

> index

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title></title>

<script language="JavaScript">
function process(){
var firstname = document.form1.firstnametxt.value;
var business = document.form1.businesstxt.value;
var county = document.form1.countytxt.value;

var stuff_for_cookie = firstname + "#*$!" + business + "xxx" + county;

document.cookie = escape(stuff_for_cookie);
window.location = "2.htm";
}
</script>
</head>

<body>
<form name="form1">
<h4>First Name:</h4>
<input type="text" size=15 name="firstnametxt"><br><br><br>
<h4>Business Type:</h4>
<input type="text" size=15 name="businesstxt"><br><br><br>
<h4>County:</h4>
<input type="text" size=20 name="countytxt"><br><br><br>

<input type="button" value="Submit" onClick="process()">
</form>

<p>&nbsp;</p>
</body>
</html>

> netxPage (2.htm)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title></title>
<script language="JavaScript">
var cookie_stuff = unescape(document.cookie);
var crumbs = cookie_stuff.split("xxx");

var firstname = crumbs[0];
var business = crumbs[1];
var county = crumbs[2];

</script>
</head>

<body>
<H1><p><script language="JavaScript">document.write(firstname)</script> we have ....</H1>

</body>
</html>