javascript - Can I use conditioned alert in php which is encoded in .html -
i developing page in on adding field data on page want alert putting alert msg in php code .i want alert in html page. have put alert message in php tag not working.
<!doctype html> <html> <body> <? if(isset($_get['succ'])) { $message1 = "name correct"; echo "<script type='text/javascript'>alert('$message');</script>"; } if(isset($_get['err'])) { $message2 = "name not saurabh"; echo "<script type='text/javascript'>alert('$message');</script>"; } <form action="action.php" method="post"> first name:<br> <input type="text" name="firstname"> <br> last name:<br> <input type="text" name="lastname"> <br><br> <input type="submit" value="submit"> </form> <p>if click "submit" button, form-data sent page</p> </body> </html>
you need use $message1
or $message2
instead of using $message.
also, need close php tags
before opening html element(form
in case).
let page url has succ
or err
in url parameter.
<?php if(isset($_get['succ'])){ $message1 = "name correct"; echo "<script type='text/javascript'>alert('".$message1."');</script>";// use $message1 not $message } else if(isset($_get['err'])){ // adding else, url contains succ or err $message2 = "name not saurabh"; echo "<script type='text/javascript'>alert('".$message2."');</script>";// use $message2 not $message } ?> <form ..... .... ....
Comments
Post a Comment