I'm using JavaScript to redirect a page with dynamic parameter.
Here is the code, I had to use the PHP function inside JavaScript. It works but it isn't using the javascipt variable
<script type="text/javascript">
var $map = jQuery.noConflict();
$map(document).ready(function(){
$map("#map_search").click(function(){
var staffname = $map("#staffname").val();//alert(staffname);
var from = $map("#cdate_from").val();
var to = "<?php echo site_Encryption(from); ?>";alert(to);
var status = $map("#status").val();
window.location = "http://localhost/staff/booking.php?date="+to+"&tdate="+to;
var to = "<?php echo site_Encryption(from); ?>";alert(to);
Here I use the PHP function and "from" is JavaScript variable that I want to use.
You can do an ajax request, something like:
var from = blablah...;
$.getJSON("encryption.php", {from : from}, function (data)
{
alert(data.to);
});
encryption.php :
<?php
blabla...
echo json_encode(array("to" => site_Encryption($_GET["from"])));
?>
(It's a sample code, don't copy-paste, read some ajax tutorials ^^)
An alternative could be to make the encryption on client side.