Results 1 to 3 of 3

Thread: displaying form data in next page

  1. #1
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default displaying form data in next page

    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>

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    I can give you an easy example in PHP. You would need a server to do this, though:

    Your first page:

    Code:
    <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

    Code:
    <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

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Server-side is indeed the way you want to go — remember, not everyone has Javascript.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •