thenashone thenashone - 3 months ago 17
PHP Question

Refreshing old page whilst closing current page and add a action in url

I am trying to close a window after a form has been submitted and to refresh the main page, then passing information within the url for a action popup.

I have the code working fine but cant seem to pass the information on.

here is the working code

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

I have tried the following and i know its wrong but not sure where to seek the answer as not too sure what to search for

// 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);

// 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>";
die('Unable to delete record.');

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

As you can tell i am trying to add
on to the end of the url.

The above code closes the window but does not add the information needed to the end, refresh is not needed now due to it will be a new url load.

Many Thanks in advance


For this you can use this

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

it changes location of current window.
For example if your page was it will redirect you to

To process your request add

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