3

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
}
1
  • 2
    Suggestion: take the time to learn/understand why you can replace $_SESSION['success'] = ($result) ? TRUE : FALSE with $_SESSION['success'] = $result or $_SESSION['success'] = !!$result depending on what $result can contain. :-) Commented Sep 15, 2011 at 21:46

3 Answers 3

3

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>";
}
Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

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

1 Comment

This will be caught by the standard popup blocking built into browsers. Windows can only be opened in response to a user-triggered event.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.