PDA

View Full Version : سوال: فرم ورود له مدیریت سایت



amin_sltny
یک شنبه 22 بهمن 1391, 10:50 صبح
سلام

دوستان من دارم یه لوگین برا سایتم می سازم که با ajax کار کنه کد هاشو به صورت زیر نوشتم

صفحه login.php


<!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()
{
$('#loginform').submit(function()
{
$('#message').removeClass().addClass('messagebox') .text('در حال بررسی...').fadeIn(1000);

$.ajax({type:POST,url:"validate.php",data:"Captcha="+$('#Captcha').val(),cache:true,success: function(data){

alert($(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('کد امنیتی اشتباه نیست!');
}
}});
$.post();
});



});

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 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 type="submit" id="submit" name="submit" value="ورود" class="button animation">

</form>

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

</body>

</html>
صفحه validate.php


<?php

session_start();
if((empty($_SESSION['Captcha']) || (isset($_POST['Captcha']) == isset($_SESSION['captcha']))))
{
die ("no");
}
else
{
die("yes");
}

?>
اما کار نمی کنه می خواستم کمک کنید من تا حالا با ajax کار نکردم

aspismylove
یک شنبه 22 بهمن 1391, 11:18 صبح
دوست عزیز این سوالت ربطی به این تالار نداره ...

برو توی تالار PHP بپرس ...