SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post variables after opening new window

    Hello.
    I'm a javascript/php beginner, I guess it's a simple question...
    I have a form to collect data. Then I want to open a new (popup) window with that data.

    This works fine:
    (...)
    <body>
    <form action="mailing.php" method="post">
    <input type="text" name="email">
    <input type="submit" value="send">
    </form>
    (...)


    With mailing.php being:
    (...)
    <body>
    <?php
    $email=$HTTP_POST_VARS['email'];
    (...)



    But I would like to open a new popup window, so I changed the code:
    (...)
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    window.open(URL, id, 'toolbar=0, scrollbars=0, location=1, statusbar=0, menubar=0, resizable=0, width=800, height=350');
    }
    // End -->
    </script>
    </head>

    <body>
    <form method="post">
    <input type="text" name="email">
    <input type="button" value="send" onClick="javascript: popUp('mailing.php')">
    </form>
    (...)


    But now, on mailing.php I'm getting:
    Notice: Undefined index: email in c:\programas\easyphp1-8\www\site\mailing.php on line x
    (where x is the number of the line $email=$HTTP_POST_VARS['email'];.)
    I don't know why, but $email is always empty in mailing.php...

    Any ideas? What is wrong?...
    Thanks

  2. #2
    SitePoint Evangelist LemoNade's Avatar
    Join Date
    Aug 2005
    Location
    Southampton, UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try using $_POST instead of $HTTP_POST_VARS:

    PHP Code:
    $email $_POST['email']; 
    -Will
    My portfolio: lemonadeX.net
    XHTML/CSS/PHP coder for hire

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks LemoNade, but with $_POST I'm getting the same error...

  4. #4
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:
    Code:
    <input type="button" value="send" onClick="javascript: popUp('mailing.php')">
    To something like:

    PHP Code:
    <input type="button" value="send" onClick="javascript: popUp(<?php 'mailing.php'".$_POST[email])?>>
    Then change the

    PHP Code:
    $email=$HTTP_POST_VARS['email']; 
    To

    PHP Code:
    email=$_POST['email']; 
    Be sure to save the page that your Form, Javascript function and other stuff is on as a .php file, otherwise it wont work.
    See how that goes.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?


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
  •