Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post

    Sending php variables

    Ok so i have a form that has a username field, a password and a confirm password field.

    When the submit button is pressed it adds that info to a database and opens a popup window with the onsubmit attribute in the form tag (the main window from before now goes back to the page to have a new user/password combo entered for another account)

    I need to know how i can have the username displayed on this popup window.

    Does anybody know how to do this?

    thanks.

  • #2
    New Coder
    Join Date
    Nov 2007
    Posts
    41
    Thanks
    5
    Thanked 1 Time in 1 Post
    You should be able to use the $_GET['fieldname'] function to display what the user has filled into the field you want to show the result of (e.g. the username field)

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    no that didn't work.

  • #4
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I think he's saying you would pass your variable in the string you use to call up your popup window, and then use the $_GET in the popup window.

    IE (URL To Popup page)
    <script>
    window.open ("your-popup-page.php?username="<?php echo $username; ?>";
    </script>

    And in the popup page:
    $username = $_GET['username'];
    echo "Thanks for signing up ".$username."!";
    Last edited by drscares; 11-04-2007 at 05:46 PM.

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    It would work if you did it properly. Post the code you're using that "didn't work" if you want help.
    Quote Originally Posted by drscares
    $username = $_GET('username');
    You need to use brackets, not parenthesis:
    $username = $_GET['username'];
    Last edited by Inigoesdr; 11-04-2007 at 05:45 PM.

  • #6
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Oops, good catch. Just woke up ;-)

  • #7
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    the method $username = $_GET['username']; still didn't work

    i tried drscares way but the popup window wouldn't work at all. I think with this way i'm doing somthing wrong.

    Here's my onsubmit code:

    onsubmit='popout("../scripts/printouts/newuser/printout.php?user=<?php echo $_POST['username']; ?>?password=<?php echo $_POST['password']; ?>, "_help",-1,-1);'

  • #8
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    View the source of the page with the JavaScript and post the URL that's generated for the popout() function. Popout is defined, right?

  • #9
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    yes popout's defined. Here's the javascript for it:

    Code:
    <SCRIPT Language="javascript">
    <!--
        uniqueUrl = 1;
    // This needs to be fixed if the current page plans to use the "bUseSame" option
    // for more than one window. ViewWin is obviously not sufficient for tracking multiple windows
        var ViewWin = null;
        function popout(url, targetWin, h, w, bTouchUrl, bUseSame )
        {
            if( bUseSame && ViewWin != null && !ViewWin.closed && ViewWin.name == targetWin )
            {
                ViewWin.focus();
            }
            else
            {
            
                if (bTouchUrl)
                {
                    if (bTouchUrl == 1)
                    {
                        url += "&z=" + uniqueUrl;
                        uniqueUrl++;
                    }
                }
                
                if (h && h > 0)
                    height=h;
                else
                    height=470;
    
                if (w && w > 0)
                    width=w;
                else
                    width=630;
    
    		if( bUseSame  )            
    ViewWin=window.open(url, targetWin,
                                'width='+width+',height='+height+',resizable=yes,menubar=yes,scrollbars=yes,status=yes' );
    		else
    window.open(url, targetWin,
                                'width='+width+',height='+height+',resizable=yes,menubar=yes,scrollbars=yes,status=yes' );
    
    
    
            }
             
        } // popout
    // -->
    </SCRIPT>
    it worked before i added the ?user=...?pass=... to the end of the url

  • #10
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Inigoesdr View Post
    View the source of the page with the JavaScript and post the URL that's generated for the popout() function. Popout is defined, right?
    Also, you're only supposed to use "?" once in the URL; it defines the start of the query string. Use "&" to separate the parts of the query string.
    Last edited by Inigoesdr; 11-04-2007 at 06:33 PM.

  • #11
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Try this:

    Code:
    onsubmit='popout("../scripts/printouts/newuser/printout.php?user=<?php echo $_POST['username']; ?>&password=<?php echo $_POST['password']; ?>", "_help",-1,-1);'

  • #12
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    ok the popup is opening again but the no data is being sent.

    the url of the popup is just this: http:// domain. com/scripts/printouts/newuser/printout.php?user=&password=

    the username & password doesn't get added in its place.

  • #13
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    here's the code from the printout.php page:

    Code:
    <?php
    
       $uname = $_GET['user'];
    
       echo $uname;
    
    ?>

  • #14
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Doom87 View Post
    ok the popup is opening again but the no data is being sent.

    the url of the popup is just this: http:// domain. com/scripts/printouts/newuser/printout.php?user=&password=

    the username & password doesn't get added in its place.
    Ok, now find out why the $_POST variables are empty. Are you not naming the form inputs? Or are you not posting the form to the correct page? etc.

  • #15
    New Coder
    Join Date
    Oct 2007
    Posts
    84
    Thanks
    0
    Thanked 8 Times in 8 Posts
    If I'm following what you are saying, this isn't going to work. The variable's aren't being passed to the javascript window onsubmit, because at that point there are no PHP post variables. The URL for the javascript window has already been created.

    Right now, your popup will show up with the right information from the first submit on the second go around.

    What you may want to do is set it up to check for POST variables, and on page load for the form, if that variable exists, open your popup window.

    I'm sorry if I am not following what you are trying to say.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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