Add php user data to a java alert

4 posts by 3 authors in: Forums > CMS Builder
Last Post: July 31   (RSS)

I have the following java script which upon right click of mouse displays a message alert.

I'm having an issue adding PHP user data such as the users name and address to the "alert section" shown in red below. Can anyone help?

Thanks - Ray

------------------------- code script ----------------------------

<!-- web page warning box upon mouse right click -->
<script language="javascript">
if (document.addEventListener) {
document.addEventListener('contextmenu', function(e) {
alert("The RIGHT CLICK and web page print functions have been deactivated. Printing and redistribution of this product is strictly prohibited"); //here you draw your own menu
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function() {
alert("The RIGHT CLICK and web page print functions have been deactivated. Printing and redistribution of this product is strictly prohibited");
window.event.returnValue = false;
});
}
</script>

nmsinc

Hi Ray,

You can echo php variables right into the JS.  Like:

alert("Hi <?php echo $firstName; ?>.");

One thing to look out for is if there are any double quotes in the echo-ed variable they will need to be escaped.

Hope that helps!
Robin

Robin
Programmer
interactivetools.com

Thanks everyone. I will give these a try!

nmsinc