 Yazar : pasion
Seviye:
|
php ve ajax ile login sayfa sorunu
--kontrol php --
[php]
<?php
/*
*kurTi Tasarým
*www.kurtitasarim.com
*kurTi 2oo9
*/
/* ayar saýtýrý */
$varmi = include ("../ayar/_ayar.php");
/* ayar satýr sonu */
function kontrolPost($giris) {
$giris = htmlspecialchars($giris);
$giris = (get_magic_quotes_gpc()?$giris:addslashes($giris));
return $giris;
}
@$kullanici = kontrolPost($_POST['kullanici']);
@$sifre = kontrolPost($_POST['sifre']);
$giris_durumu = TRUE;
$sql = "SELECT * FROM admingiris WHERE kullanici='$kullanici'";
if($sql>0) {
$sorgu = "SELECT * FROM admingiris WHERE kullanici='$kullanici' AND sifre='$sifre'";
$sorug1 = mysql_query($sorgu);
if($sorgu)
{$giris_durumu=TRUE;}
else
{ $giris_durumu=FALSE; } }
else
{ $giris_durumu=FALSE; }
/* Sonuç ver */
if ($giris_durumu) {
$_SESSION['kul']=$kullanici;
echo "Ok";
} else {
echo "Hatali";
}
?>
[/php]
--panel js --
[php]
function ekle(){
if( document.getElementById('kullanici').value.length < 1 ) {
$('div.durum').html( '<div class="hata">Lütfen Kullanıcı Adınızı giriniz!</div>');
}
else if( document.getElementById('sifre').value.length < 1 ) {
$('div.durum').html( '<div class="hata">Lütfen Parolanızı giriniz!</div>');
}
else {
var a = "kullanici="+document.getElementById('kullanici').value;
var b = "sifre="+document.getElementById('sifre').value;
var sc = a+"&"+b;
$('div.durum').html('<br /><center><img src="loadingAnimation.gif"></center>');
$.ajax({
type: "POST",
url: "kontrol.php",
data: sc,
success: function(msg){
if (msg=="ok")
{
$('div.durum').html('<div class="tamam">Giriş Başarılı :) Panele yönlendiriliyorsunuz...</div>');
setTimeout("window.location = 'index.php';",1000);
}
else
{$('div.durum').html( '<div class="hata">'+msg+'</div>');}
}
});
}
}
[/php]
--login php--
[php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/style.css" type="text/css">
<!-- JS -->
<script type="text/javascript" src="js/panel.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<!-- JS Sonu -->
<style type="text/css">
<!--
body {
background:#333333 url(resim/login/bg.png);
}
-->
</style></head>
<body>
<div id="login">
<form method="post" action="javascript:void(0);">
<div id="input_1">
<input type="text" name="kullanici" id="kullanici" class="kul" maxlength="18">
<div id="input_2">
<input type="password" name="sifre" id="sifre" class="kul" maxlength="16"></div>
<div id="submit">
<input onclick="ekle();" type="submit" value="" class="submit"></div>
<div class="durum"></div>
</div>
</body>
</html>
[/php]
sorunum şu k.adı ve şifremi doğru girmemem rahmen hata veriyor
|