compare click count on image with click count recorded in database
<p>I am developing an extremely simple login system for myself, not going to publish it online.
My scenario : During registration, user chooses his username and insert desired click count(s) for login and it will be stored in database. During login, user will first key in his username, then user will be redirect to a page where user will click on an image with onclick function to count the click(s).</p>

<p>Problem : How can I get the "click count(s)" from login.php and then compare with the database recorded clicks in checkclick.php ? I have tried my best to find my own idea to do it for days already. However, i failed. To be honest, i am slow and weak in programming, so i hope i can get some helps here. My friends did suggest me to use AJAX, but after went through the tutorial, i don't really understand. Can anyone please help ? I will be grateful.</p>

<p>Thank you so much for reading and helping on my question.</p>

<pre><code>login.php    

&lt;?php
include("connection.php");
$username = $_SESSION["CID"];
$table1=mysql_query("select * from pic_a");
$table2=mysql_query("select * from pic_b");
$table3=mysql_query("select * from pic_c");

$tab1[0]=0;
$tab2[0]=0;
$tab3[0]=0;

$i=0;
while($row=mysql_fetch_assoc($table1))
{
    $tab1[$i]= $row["pic_link"];
    $i++;
}

$i=0;
while($row=mysql_fetch_assoc($table2))
{
    $tab2[$i]= $row["pic_link"];
    $i++;
}

$i=0;
while($row=mysql_fetch_assoc($table3))
{
    $tab3[$i]= $row["pic_link"];
    $i++;
}


$rand1=rand(0,9);
$rand2=rand(0,9);
$rand3=rand(0,9);


?&gt;
&lt;script type="text/javascript"&gt;
var count = 0;
function countClicks() {
count = count + 1;
document.getElementById("clicks").innerHTML = count;
}
&lt;/script&gt;

&lt;body&gt;
&lt;h1&gt;login&lt;/h1&gt;

    &lt;form action = "" name = "allpass" method = "post" enctype = "multipart/form-data"&gt;

        &lt;p style="font-size:20px"&gt;Username: &lt;?php echo $username;?&gt; &lt;/p&gt;
        &lt;p style="font-size:20px"&gt;Password:&lt;/p&gt;
    &lt;p&gt;&lt;table border = 0&gt;

    &lt;td&gt;
        &lt;div STYLE=" height: 800px; width: 165px; font-size: 12px;"&gt;
    &lt;table border="1"&gt;
         &lt;tr id="bird" onclick="countClicks();"&gt;
            &lt;td&gt;&lt;img src="password\&lt;?php echo $tab1[$rand1]; ?&gt;" alt="" width="76" height="67"&gt;&lt;/td&gt;
            &lt;td&gt;Bird&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr id="car" onclick="countClicks();"&gt;
            &lt;td&gt;&lt;img src="password\&lt;?php echo $tab2[$rand2]; ?&gt;" alt="" width="76" height="67"&gt;&lt;/td&gt;
            &lt;td&gt;Car&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr id="computer" onclick="countClicks();"&gt;
            &lt;td&gt;&lt;img src="password\&lt;?php echo $tab3[$rand3]; ?&gt;" alt="" width="76" height="67"&gt;&lt;/td&gt;
        &lt;/table&gt;
        &lt;/div&gt;
        &lt;/td&gt;
        &lt;/table&gt;
        &lt;p id="clicks"&gt;0&lt;/p&gt;
        &lt;input type = "submit" style=" height: 25px; width: 75px" value = "Login" name = "submitbtn" /&gt;
&lt;/form&gt;&lt;/p&gt;
&lt;/div&gt;


&lt;/body&gt;
&lt;/html&gt;

checkclicks.php
&lt;?php
    include("connection.php");


if(!isset($_GET["username"]) || !isset($_GET["clicks"]))
die("Error");
    $username = $_GET["username"];
    $jsClicks = $_GET["clicks"];
    $phpClicks = null;

$data = mysql_query("SELECT clicks FROM customerdetails WHERE customer_username='$username'");
while($row = mysql_fetch_array($data))
{
$phpClicks = $row["clicks"];
}
    if( $phpClicks == $clicks)
    {
    ?&gt;
    &lt;script type="text/javascript"&gt;
        alert("success");
        location = "welcome.php";
    &lt;/script&gt;
&lt;?php
} else {
?&gt;
    &lt;script type="text/javascript"&gt;
        alert("fail");
        location = "login.php";
    &lt;/script&gt;

&lt;?php
}
?&gt;
</code></pre>
