So, all this is new to me... but I am almost certain that I have this right.. however, it's not working <?php $Month = 2592000 + time(); //this adds 30 days to the current time setcookie(warning, 1 , $Month); // sets cookie with name warning, value of 1, and expiry date ?> <?php if ($HTTP_cookie_VARS[warning] == "1") { echo "document.write('<javascript>showPopUp();</javascript>')" } else { /*do nothing...*/ } ?> PHP: <script>showPopUp() { tb_show('WARNING!', '{$mybb->settings['bburl']}/warning.html?width=250&height=300&modal=true'); }</script> Code (markup): Can anyone see where I am going wrong here? What I want to happen is the the JavaScript to run only if in the cookie there is a value of 1. (as the javascript is a warning pop up box, telling users they have to be 18+ to enter) Thanks, Jam
Maybe... <?php $Month = 2592000 + time(); //this adds 30 days to the current time setcookie(warning, 1 , $Month); // sets cookie with name warning, value of 1, and expiry date ?> <?php if ($HTTP_cookie_VARS[warning] == "1") { echo "document.write('<javascript>showPopUp();</javascript>')"; } else { echo null; } ?> Code (markup):
Thanks for your reply... When I use the code that you provided, nothing still happen,and get this displaying on the screen: So take it that there is something wrong with the echo statement? Thanks, Jam
try this <?php $Month = 2592000 + time(); //this adds 30 days to the current time setcookie('warning', 1 , $Month); // sets cookie with name warning, value of 1, and expiry date ?> <?php if ($HTTP_cookie_VARS['warning'] == "1") { echo "document.write('<script type=\"text/javascript\">showPopUp();</script>')"; } else { /*do nothing...*/ } ?> PHP: