السلام عليكم ورحمة الله وبركاته
عندى مشكلة فى الكابتشا وهي تخطى التحقق من الكابتشا عند الضغط على الارسال
ياليت تصححون لى الكود :S
<?php
include('../config.php');
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from form
$myusername=addslashes($_POST['username']);
$mypassword=md5($_POST['password']);
$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;
header("location: index.php");
}
else
{
$error="اسم المستخدم أو كلمة المرور خاطئة حاول مره اخرى ";
}
}
?>
<?php
session_start();
$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];
if(isset($_POST['Submit']))
{
$captcha=(int)$_POST['captcha'];
if($captcha != $_SESSION['expect']
)
$error='The captcha code is wrong!';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>تسجيل الدخول</title>
<style type="text/css">
body
{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
background-color:#bbb;
}
.box {
width:300px;
border: solid 1px #d0e0ef;
background-color:#eee;
margin:100px auto;
}
.title {
background-color:#d0e0ef;
color:#2f557c;
padding:3px;
text-align: center;
}
.submit
{
width: 120px;
padding: 2px;
color:#2f557c;
background:#d0e0ef;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 16px;
font-weight:bold;
border: 1px solid #cecece;
float:right;
}
.input
{
width: 220px;
padding: 6px;
color:#bbb;
direction:rtl;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 13px;
border: 1px solid #cecece;
}
.error {
font-size:13px;
font-weight:bold;
color:#ff0000;
margin-top:20px
}
.post{
margin:30px
}
.post b{
margin-left:2px;
color:#2f557c;
font-size: 15px;
font-weight:bold;
}
</style>
</head>
<div class="box">
<div class="title"><b>تسجيل الدخول</b></div>
<div class="post">
<form action="" method="post">
<input type="text" name="username" class="input" value="اسم المستخدم"/>
<br /><br />
<input type="password" name="password" class="input" value="كلمة المرور" />
<br/><br />
<label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label>
<input type="text" class="" name="captcha" id="captcha" />
<input type="submit" class="submit" value=" دخول "/><br />
</form>
<div class="error"><?php echo $error; ?></div>
</div>
</div>
</body>
</html>