我正在爲自己開發一個非常簡單的登錄系統,而不會在線發佈它。 我的場景:在註冊期間,用戶選擇他的用戶名並插入所需的點擊次數以登錄,並將其存儲在數據庫中。在登錄過程中,用戶將首先輸入他的用戶名,然後用戶將被重定向到一個頁面,用戶點擊帶有onclick功能的圖片來計算點擊次數。比較圖片上的點擊次數,點擊次數記錄在數據庫中
問題:如何從login.php獲取「點擊次數」,然後與checkclick.php中的數據庫記錄點擊進行比較?我已盡全力找到自己的想法,已經有好幾天了。但是,我失敗了。說實話,我在編程上很慢並且軟弱,所以我希望我能在這裏得到一些幫助。我的朋友確實建議我使用AJAX,但在閱讀完教程後,我不太明白。任何人都可以幫忙嗎?我會很感激。
非常感謝你的閱讀和幫助我的問題。
login.php
<?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);
?>
<script type="text/javascript">
var count = 0;
function countClicks() {
count = count + 1;
document.getElementById("clicks").innerHTML = count;
}
</script>
<body>
<h1>login</h1>
<form action = "" name = "allpass" method = "post" enctype = "multipart/form-data">
<p style="font-size:20px">Username: <?php echo $username;?> </p>
<p style="font-size:20px">Password:</p>
<p><table border = 0>
<td>
<div STYLE=" height: 800px; width: 165px; font-size: 12px;">
<table border="1">
<tr id="bird" onclick="countClicks();">
<td><img src="password\<?php echo $tab1[$rand1]; ?>" alt="" width="76" height="67"></td>
<td>Bird</td>
</tr>
<tr id="car" onclick="countClicks();">
<td><img src="password\<?php echo $tab2[$rand2]; ?>" alt="" width="76" height="67"></td>
<td>Car</td>
</tr>
<tr id="computer" onclick="countClicks();">
<td><img src="password\<?php echo $tab3[$rand3]; ?>" alt="" width="76" height="67"></td>
</table>
</div>
</td>
</table>
<p id="clicks">0</p>
<input type = "submit" style=" height: 25px; width: 75px" value = "Login" name = "submitbtn" />
</form></p>
</div>
</body>
</html>
checkclicks.php
<?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)
{
?>
<script type="text/javascript">
alert("success");
location = "welcome.php";
</script>
<?php
} else {
?>
<script type="text/javascript">
alert("fail");
location = "login.php";
</script>
<?php
}
?>
顯然C.K.並沒有用這種認證方法來尋找最強的安全性,但是這個解決方案的問題在於你有效地將密碼以明文形式發送給客戶端,並詢問客戶端是否輸入了正確的密碼。 –
首先,我只是嘗試了一個基本的例子,因爲他們說他們不會在網上發佈它。我知道java顯示代碼;但php不會顯示......如果他們首先輸入了正確的密碼,他們只會看到「正確的」密碼。但我可以看到你的觀點。 –