0

I want to save cnt1 and tim into MySql database. 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. 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. 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";
    }
}

1 Answer 1

1

just sent them over to php page by concatenating in url

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

$_GET['tim'];
$_GET['cnt1'];
Sign up to request clarification or add additional context in comments.

2 Comments

cannot. ): I am using this hscripts.com/scripts/jquery/memory-game.php codes if you are willing to help me look at the whole codes.
Hey it works somehow after i changed the codes here and there! Thankyou for suggesting concatenating into url.. it makes my life so so much easier! Thanksss! You guys who respond to questions are simply awesome!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.