PDA

View Full Version : سوال: ساخت فرم لوگین با ajax



amin_sltny
یک شنبه 22 بهمن 1391, 11:31 صبح
سلام دوستان من دارم یه فرم لوگین با آجاکس می سازم

فرم لوگینم به صورت زیره:


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>مدیریت سایت</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../include/JQurey.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#submit').click(function()
{
$('#message').removeClass().addClass('messagebox') .text('در حال بررسی...').fadeIn(1000);

$.post({url:"validate.php",Captcha:$('#Captcha').val(),success: function(data){

if(data=='no')
{
alert('کد امنیتی اشتباه نیست!');
$('#message').fadeIn(2000,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('كد امنيتي وارد شده صحيح نيست!').addClass('messageboxerror').fadeTo(900 ,1);
});
}
else
{
alert('کد امنیتی اشتباه نیست!');
$('#message').fadeIn(2000,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('كد امنيتي وارد شده صحيح است!').addClass('messageboxerror').fadeTo(900,1 );
});
}
}});
});
});

function refreshCaptcha()
{
document.getElementById('psec').src='../include/piccode/index.php';

}

</script>
</head>

<body>
<div class="top">
مدیریت سایت بازی سرا
</div>
<div class="login">
<form class="loginform" id="loginform" method="post" action="">

<label for="" style="color:#F60;display:none;" id="message" ></label>
<label>نام کاربری:<input type="text" value="" class="field" id="username"></label><div style="clear:both">
<label>کلمه عبور:<input type="password" value="" class="field" id="Password"></label>
<div style="clear:both">

<div class="psec">
<img width="150" height="50" id="psec" src="../include/piccode/index.php">

<label>کد امنیتی:<input type="text" value="" class="field" name="Captcha" id="Captcha"></label>

<label>اگر قادر به خواندن کد امنیتی نیستید <a href="javascript: refreshCaptcha();" style="text-decoration:none;">اینجا </a> کلید کنید!</label>
</div>
<div style="clear:both">

<input name="Submit" type="button" id="submit" value=" ورود " class="button animation"/>

</form>

<div style="clear:both">
</div>

</body>
</html>


وفرم validator.php

<?php session_start();

if(empty($_SESSION['Captcha'] ) || strcasecmp($_SESSION['captcha'], $_POST['Captcha']) != 0)
{
die("no");
} else
die("yes");

?>

ولی ظاهرا در اجرا ایراد داره می خواستم اگه میشه کمکم کنید من تا به حال اجاکس کا رنکردم با تشکر

SadeghPro19
یک شنبه 22 بهمن 1391, 11:53 صبح
خب میشه لطف کنید بگید چه اخطاری میده؟ یا کلا چیزی نشون میده یا نه؟

siavashsay
یک شنبه 22 بهمن 1391, 17:54 عصر
نام متغیر ها نسبت به حروف بزرگ و کوچک حساس هست !
توی این کد حروف اول متغیر سشن رو یک بار بزرگ و یکبار کوچک عنوان کردید !
اونها رو اصلاح کنید ! شاید مشکل حل شد !

if(empty($_SESSION['Captcha'] ) || strcasecmp($_SESSION['captcha'], $_POST['Captcha']) != 0)