sp136
sp136

Reputation: 3

PHP: popup window

How can I make a popup alert window in a php site, depending by a variable, not by clicking a link or button?

example:

if ($a==1) {
alert(Good value!);
}else{
alert(Wrong value!);
}

Upvotes: 0

Views: 2990

Answers (2)

Donny van V
Donny van V

Reputation: 961

Not a realy smart solution... People with a popup blocker wont see the popup... I prefer to jQuery with some HTML and PHP. If you wanne use it with POST data, try some AJAX, realy helps a lot. If you wanne use it for a POST, i can write you a small piece of code if you would like, let me know

Upvotes: 0

Robbert
Robbert

Reputation: 6582

PHP itself can't interact with the client. You will have to have the PHP script output a JavaScript solution.

echo '<script type="text/javascript">';
if ($a==1) {  
  echo "alert('Good value!');";
}else{
  echo "alert('Wrong value!');";
}
echo '</script>';

Upvotes: 1

Related Questions