Updating an old page when closing the current page and adding an action to the URL

I am trying to close the window after submitting the form and refreshing the main page and then passing the information in the url for the action popup.

I have some code that works fine, but can not seem to be passing information.

here is the working code

echo "<script>window.close();window.opener.location.reload(true);</script>";

I tried the following, and I know it incorrectly, but I'm not sure where to look for the answer, because I'm not too sure what to look for

<?php
// include database connection
 $id=isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// include database connection
include '../../../assets/connect.php';

try {

    // get record ID
    // isset() is a PHP function used to verify if a value is there or not

    // delete query
    $query = "DELETE FROM investment_return Where id = '$id'";
    $stmt = $con->prepare($query);
    $stmt->bindParam(1, $id);

    if($stmt->execute()){
        // redirect to read records page and 
        // tell the user record was deleted
            echo "<script>window.close();window.location.href = window.location.href + '?action=entered';</script>";
    }else{
        die('Unable to delete record.');
    }
}

// show error
catch(PDOException $exception){
    die('ERROR: ' . $exception->getMessage());
}
?> 

As you can tell, I'm trying to append ?action=entereda URL to the end.

The above code closes the window, but does not add the necessary information to the end, an update is not required now because it will be a new URL download.

Thank you very much in advance

+4
1

window.location.href = window.location.href + "?action=entered";

window.
, https://www.google.com, https://www.google.com?action=entered

,

if (isset($_GET['action'] && $_GET['action'] == 'enabled') {
    //here add your code for example
    echo "<script>alert('deleted');</script>"
}
+3

Source: https://habr.com/ru/post/1660578/


All Articles