i want to use alert box in php but i'm confuse because alert box usually used in javascript. i want to use the alert box to control the condition if the user doesn't habe account to enter my website. can anybody help me? thanks
use alert box in php
Collapse
X
-
PHP does not have an alert box identical to JS, but you can construct a box just like that (using CSS) in PHP and display that on the screen.
Ronald :cool: -
You could go another way. Output the alert text to an html element with a certain class or id and then check with javascript if the element has content and if it has display an alert.
For the example i will use jquery to code the javascript side.
[PHP]
if($var == 'bad'){
echo '<p id="error">You made a bad move</p>';
}
[/PHP]
IMHO on the javascript side there are nicer solutions then an alert box.Code:$(function(){ var error = $('#error').text(); if(error.length > 0){ alert(error); } });Comment
Comment