Results 1 to 3 of 3

Thread: [RESOLVED] PHP-JavaScript save to SQL and close?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Resolved [RESOLVED] PHP-JavaScript save to SQL and close?

    I have two buttons in a pop-up window, a save and close...
    HTML Code:
    <input type="button" class="box" onClick="window.close()" value="Close Page" />
    <input name="Save" class="box" type="submit" value="Save Record" />
    PHP Code:
    if($_POST['Save']){


    mysql_select_db("ArborealClients"$con);
    if (
    in_array("$lastname",$oneclient)){
    mysql_query("UPDATE DB SET x='$y' WHERE a='$b' LIMIT 1");
    }else{
    mysql_query("INSERT INTO DB (x ) VALUES ('$y')");
    }} 
    How can I combine the two so theres one button to save the information and then close the window?

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: PHP-JavaScript save to SQL and close?

    you should be able to just call window.close() onload of the <body> tag.
    PHP Code:
    <?php
      
    //do php stuff.
    ?>
    <body onload="window.close()">
      <!-- blah -->
    </body>
    I think that could work.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Re: PHP-JavaScript save to SQL and close?

    thanks I've done this...
    PHP Code:
    <body>

    <!-- html code & button -->

    <?php  if ($_POST['save'])
    echo 
    "</body>";
    echo 
    "<body onload=\"window.close()\">";
    ?>
    </body>

Posting Permissions

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



Click Here to Expand Forum to Full Width