SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Open and close browser

    Hi guys, I'm not exactly a js guru so would appreciate some help.

    I'm running a bat file that runs a php script, that backs up my db.

    Problem is that I'm limited by the functions I can use as I'm on a winXP box and dont want to compromise security.

    The function I'm left with means I should run the script from a browser as it echoes out the results. At this point I'm not opening a browser so it is creating a few problems.

    To get around this I thought I might be able to use js. But, I've been testing with a script I hacked (and I mean hacked, its probably a mess).

    4 problems:
    1. its trying to download a file
    2. still has a pop-up asking if its ok to close window
    3. its not displaying the php file
    4. even if I click the 'go back' link it still asks if it should close.

    I will enclose the php script I'm running from bat file in the hopes some-one will kindly put it all together for me
    For testing I've just been running (trying to include, not download, as I'm getting now) a small php script that says 'hello world'

    Thanks in advance

    JS
    Code:
    <html>
    <head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function OpenWindow(theURL,winName,features) { 
    window.open(theURL,winName,features);
    window.blur();
    setTimeout("window.close();",30000); // gives enough time to backup db
     
    }
    //-->
    </script>
     
    </head>
    <body bgcolor="#FFFFFF" onLoad="OpenWindow('testmyclose.php','','')">
    <a href="javascript: self.close()">go back</a>
    </body>
    </html>
    PHP Code:
    <?php
    include('efxdb_connect.php');
        
    error_reporting(E_ERROR E_WARNING E_NOTICE);
     
     
    // Database Backup Filename & Location
        
    $backupto 'C:/backup/'// absolute path to folder containing database - no trailing slash.
        
    $backupas 'efx' date("-l-F-j-Y-g-i-a") . '.sql';
    // Perform backup
    $backupcommand "c:/mysql/bin/mysqldump -u$efxdbuser -p$efxdbpassword $efxdbname>$backupto/$backupas";
    passthru ($backupcommand$error);
    if(
    $error) {
    echo (
    "Problem: $error<br>\n" );
    echo 
    $backupas;
             }
    else
    {
    echo 
    "Yip,yip, YIPPY KI A";
    }
        exit;
    /*c:\mysql\bin\*/
    ?>

  2. #2
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, I'm running this on my own box


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
  •