ユーザーが間違ったユーザー名とパスワードを 3 回入力したときに、次のコードを使用して管理者にメッセージを送信しました。
このコードの問題をデバッグするのを手伝ってください。次のコードで管理者にメッセージを送信するにはどうすればよいですか?
<?php
session_start();
$cookie_var_attempts=0;
if(isset($_POST['username']))
{
$uname=$_POST['username'];
$password=$_POST['password'];
mysql_connect('localhost','root','');
mysql_select_db('gps_test1');
$sql="select * from tbl_user where uname='$uname' and password='$password'";
$query=mysql_query($sql);
$no_of_rows=mysql_num_rows($query);
if($no_of_rows==1)
{
$_SESSION['username']=$uname;
header('location:track_map.php');
}
else
{
if($cookie_var_attempts>=3)
{
echo"message is sent to admin";
}
else
{
echo "Enter the correct username and password";
$cookie_var_attempts++;
}
}
}
?>