How to put php variable in JS link

0

Hello everyone, how are you? I'm having trouble putting PHP variable in JS link, which I need to know because I'm trying to make a login system u on my site ... they see the line of code r get a supposed solution. Thanks in advance !!!!!!!!

My problem is that I have this command line in JavaScript that is inside the file:

<?
$opts = uniqid(rand(), true);
echo "<script> window.location.assign('http://localhost/web/'" . $opts . '") </script>;
?> 

but this line of code simply does not occur at all ... How to proceed?

    
asked by anonymous 02.11.2016 / 23:22

1 answer

0

Try the following block:

<?
$opts = uniqid(rand(), true);
echo "<script> window.location.assign('http://localhost/web/" . $opts . "') </script>";
?> 

You are not closing " after tag <script>

You're putting ' more, see: 'http://localhost/web/'" . $opts . '"

So if the value of the variable is page1 it will be printed: 'http://localhost/web/'page1

    
02.11.2016 / 23:33