herghost Posted April 21, 2009 Share Posted April 21, 2009 Is it possible to do a purely PHP popup message box? I cant seem to find one that doesnt involve java or ajax! Basically I have this: if(isset($_GET['update'])) { echo "thanks for registering, you may now login"; } and I want the text to pop up in a box? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/155112-solved-php-popup/ Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 21, 2009 Share Posted April 21, 2009 No you can't. PHP is server-side. You need a client-side script like javascript (which is very different from java btw). Quote Link to comment https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815953 Share on other sites More sharing options...
herghost Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks, I have tried putting a javascript query in here, but I cant work out how to do it with php, any pointers? I have tried this: if(isset($_GET['update'])) { echo "<SCRIPT LANGUAGE='javascript'>window.onload=function(popupMsg('message here'));</SCRIPT>"; } and calling this in the header function popupMsg(msg) { alert(msg); } but to no avail Quote Link to comment https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815954 Share on other sites More sharing options...
rondog Posted April 21, 2009 Share Posted April 21, 2009 I tried this and it works <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <?php if(isset($_GET['update'])) { echo "<SCRIPT LANGUAGE='javascript'>window.onload=alert('message here');</SCRIPT>"; } ?> </head> <body> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815978 Share on other sites More sharing options...
premiso Posted April 21, 2009 Share Posted April 21, 2009 Just fixing outdated code. echo "<script type='text/javascript'>window.onload=alert('message here');</script>"; The language attribute has been depreciated for a while. It is better to use the type="text/javascript" for correct markup etc. Why even add the window.onload? Just simply calling alert would work. Quote Link to comment https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815998 Share on other sites More sharing options...
herghost Posted April 22, 2009 Author Share Posted April 22, 2009 Thanks all: Went with this in the end: <?php if(isset($_GET['basics'])) { echo "<script language=javascript>alert('Information Updated.')</script>"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-816685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.