John
John

Reputation: 39

How to create a pop up window using php via echo?

Is it possible to make a pop up window in my existing script?

session_start();

$_SESSION['success'] = ($result) ? TRUE : FALSE;

header('location: inv_fc.php');

session_start();
if ($_SESSION['success'] == TRUE) {
// CREATE POP UP WINDOW SUCCESS
} else {
// CREATE POP UP WINDOW FAILURE
}

Upvotes: 3

Views: 45014

Answers (3)

Naftali
Naftali

Reputation: 146360

<?php if ($_SESSION['success'] == TRUE)?>
  <script>window.open(...);alert('Your Awesome!');</script>
<?php else ?>
  <script>window.open(...);alert('You Fail!!');</script>
<?php endif; ?>

Upvotes: -1

Griwes
Griwes

Reputation: 9059

You could open a pop-up using javascript or target a's attribute, but it's impossible from PHP, which is executed at server side.

Edit: ok, as I saw the <script> things: it's not PHP, it's Javascript, from PHP it's not possible.

Upvotes: 3

someone
someone

Reputation: 1468

You can do it with Javascript. For nicer results, use jQuery UI.

if ($_SESSION['success'] == TRUE) {
    echo "<script>alert('Success!');</script>";
} else {
    echo "<script>alert('Failure.');</script>";
}

Upvotes: 3

Related Questions