I need to get to another page and post some data. I want to post Javascript variable from "index.php" and get PHP variable on "zakazka.php". I need to start the function with click on span text, so I don't want to use form.
I had found that redirect will help me, but can't make a simple example work -
Index.php:
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
</head>
<body>
<?php
session_start();
$user="abc";
$_SESSION["user"] = $user;
?>
<span id="1" onclick="get()">hello</span>
</body>
</html>
<script>
function get()
{
kod="1";
$.redirect('zakazka.php', {'kodsend': kod});
}
</script>
Zakazka.php:
<?php
session_start();
$user=$_SESSION['user'];
$kodr = $_POST['kodsend'];
echo $kodr;
?>