SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using Java after Inserting info into database question.

    Hi I have not been able to find any information on google about this. I am trying to figure out how to implement a java pop up window after making a mysql INSERT INTO query.

    I would want to carry over a variable if it is possible. Can anyone tell me if this is possible and point me to a link which would include some information setting me in the right direction so I can try to accomplish this?

    Here is the java code I would like to use.

    Code:
    <a href="javascript:;" onclick="MM_openBrWindow('settings.php','up1','scrollbars=yes,width=750,height=500')" class="FooterLinks">"here"</a>
    After someone clicks the submit button to become a member to my site. The memebers info is inserted into the database. I want to pop open the member settings page (settings.php?MemberID=) with thier memberID attached in a new window not in the main browser so they can edit some setting info. In the main browser I want to land the new member on a thank you/welcome page.

  2. #2
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would suggest using sessions to do this. When the data is added to the database also add it to the PHP session
    PHP Code:
    <?php $SESSION['memberid'] = $_POST['memberid']; ?>
    In the popup window you can retrieve the variable like this:

    PHP Code:
    Your member id is: <?php echo $SESSION['memberid']; ?>
    Have a look at http://uk2.php.net/session for official info on sessions or just google session tutorial Session Tutorial.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrwooster View Post
    I would suggest using sessions to do this. When the data is added to the database also add it to the PHP session
    PHP Code:
    <?php $SESSION['memberid'] = $_POST['memberid']; ?>
    In the popup window you can retrieve the variable like this:

    PHP Code:
    Your member id is: <?php echo $SESSION['memberid']; ?>
    Have a look at http://uk2.php.net/session for official info on sessions or just google session tutorial Session Tutorial.
    Ok that is very useful thank you, now I need to find out how to after inserting the members info into the database then execute the javascript pop up window. Once I can accomplish this then I will try to pass the members ID to the pop up so they can change settings.

  4. #4
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You do not need to add the info to the database first if you use sessions.

    I suggest that you call the popup when the user clicks on the submit button (you do realise that about 50% of the time it will not work as users will have blocked popups).

    The data will then be added to the database, and the member can change his preferences.

    HTML Code:
     <input type="submit" onclick="show popup" />

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrwooster View Post
    You do not need to add the info to the database first if you use sessions.

    I suggest that you call the popup when the user clicks on the submit button (you do realise that about 50% of the time it will not work as users will have blocked popups).

    The data will then be added to the database, and the member can change his preferences.

    HTML Code:
     <input type="submit" onclick="show popup" />
    Thank you for the help. I appreciate it.

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrwooster View Post
    I would suggest using sessions to do this. When the data is added to the database also add it to the PHP session
    PHP Code:
    <?php $SESSION['memberid'] = $_POST['memberid']; ?>
    In the popup window you can retrieve the variable like this:

    PHP Code:
    Your member id is: <?php echo $SESSION['memberid']; ?>
    Have a look at http://uk2.php.net/session for official info on sessions or just google session tutorial Session Tutorial.
    Ok I am really new at this I have been trying to figure this out since you last posted this. I can not seem to get it to work. Where would I put these two lines of code? I am sorry I am a newb. TY for the help.

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh by the way I am running SSL on both site can I safely pass the session id thru the url?

  8. #8
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok,

    You would have something like this:

    Form page:
    form.php
    HTML Code:
    <form action="members.php" method="POST">
    Type something<input type="text" name="test">
    <input type="submit">
    </form>
    members.php
    PHP Code:
    <html>
    <head> ... </head>
    <script type="text/javascript">
    function poponload() {
     window.open ("http://www.yoursite.com/memberspopup.php",
    "mywindow","menubar=1,resizable=1,width=350,height=250"); 
    }
    </script>
    <body onload="javascript: poponload()">
    <?php
    $var 
    $_POST['text'];
    $_SESSION['text'] = $var;
    $sql "INSERT ...." // insert data into database
    ?>
    memberspopup.php
    PHP Code:
    <?php
    $var 
    $_SESSION['text'];
    echo 
    'the text is: '.$var;
    ?>

    I have not tested the code at all so I am sure there are errors but the basic idea is that as well as submitting the data to the database, you also save it in the session and then retrieve the session data in the popup window. Note you will have to call
    PHP Code:
    <?php session_start(); ?>
    at the start of each page. You could also query the database from the popup page, but I think that using sessions is probably a better way to do it.

    Oh by the way I am running SSL on both site can I safely pass the session id thru the url?
    Not sure, are you saying that you are using two separate websites or that you want to pass the session id between pages on the same website?


    Regards,

    Guy


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
  •