是否将Javascript变量保存为PHP变量?获取、发布、COOKIE


Save Javascript variable to PHP variable? GET, POST, COOKIE

我想将cnt1tim保存到MySql数据库中。我知道Javascript是客户端,而PHP是服务器端,可用的选项是使用POST GETCOOKIE方法。但我似乎无法应用我的代码。

这实际上是一个记忆游戏http://www.hscripts.com/scripts/jquery/memory-game.php,要玩游戏,链接是http://www.hscripts.com/scripts/jquery/memory-game.php.我想节省所花费的时间和移动次数。

有什么建议吗?非常感谢。

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";
    }
}

刚刚通过链接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;
    }

并作为访问php页面

$_GET['tim'];
$_GET['cnt1'];