How To Add A Javascript Alert With A Php Script?
let's say i have an input form, wherein, it's use for an email address. this form is part of a long form so i use an alert box instead when other inputs got errors....my question n
Solution 1:
PHP is server-side language. you can output it to user with
echo"<script>alert('".mysql_real_escape_string($errormessage)."');</script>";
or you can write your own function
functionalert($a){
echo"<script>alert('".mysql_real_escape_string($a)."');</script>";
}
alert("test");
Solution 2:
You can echo any kind of javascript with PHP. The question is however, are you sure you want to do this? You can also do like this:
<?phpif(emailExists): ?><script>alert('Email exists!')</script><?phpendif; ?>
But you could also use jQuery and Ajax requests to check if email exists with ajax when user has typed the email.
Solution 3:
echo '<script>alert("ssss");</script>' ;
just put it within echo it will work that way
Post a Comment for "How To Add A Javascript Alert With A Php Script?"