[英]Save Javascript variable to PHP variable? GET, POST, COOKIE
I want to save cnt1
and tim
into MySql database. 我想将
cnt1
和tim
保存到MySql数据库中。 I understand that Javascript is the client side while PHP is the server side and the available options are to use the POST GET
and COOKIE
method. 我知道Javascript是客户端,而PHP是服务器端,可用的选项是使用
POST GET
和COOKIE
方法。 But I can't seem to apply in my code. 但是我似乎无法在我的代码中应用。
It is actually a memory game from http://www.hscripts.com/scripts/jquery/memory-game.php , to play the game the link is http://www.hscripts.com/scripts/jquery/memory-game.php . 它实际上是来自http://www.hscripts.com/scripts/jquery/memory-game.php的记忆游戏,要玩的游戏链接为http://www.hscripts.com/scripts/jquery/memory- game.php 。 I want to save the time taken and number of moves.
我想节省时间和移动次数。
Any advice? 有什么建议吗? Please and thank you very much.
请,非常感谢你。
function finish()
{
var cnt1 = $("#counting").val();
var tim=$("#timecount").val();
alert("Congratulations! You have won the game Total Move : "+cnt1+" Time : "+tim+" seconds");
if(confirm("Do you want to play again"))
{
stopCount();
window.location.href="index.php";
}
else
{
window.location.href="leaderboard.php";
}
}
just sent them over to php page by concatenating in url 刚刚通过连接url将它们发送到php页面
if(confirm("Do you want to play again"))
{
stopCount();
window.location.href="index.php?cnt1="+cnt1+"&time="+tim;
}
else
{
window.location.href="leaderboard.php?cnt1="+cnt1+"&time="+tim;
}
and access on php page as 并在php页面上访问为
$_GET['tim'];
$_GET['cnt1'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.