Millica Millica - 3 months ago 7
Javascript Question

How do I add php to a url?

I want to re-direct the link below in a javascript function, but I'm unsure how to properly call the php code listed after

?u=
. I've tried the example below and also
inbox.php?u=<?php $log_username; ?>
but it doesn't work. Can somebody guide me in the right direction?

window.location.replace("inbox.php?u='.$log_username.'");

Answer

You have missed the echo in the php tag. Try with:

window.location.replace("inbox.php?u=<?php echo $log_username; ?>");
Comments