KODLAR : JS SAYFASI
$(function(){
$("#btn-login").click(function(){
var username = $("#login-username").val();
var password = $("#login-password").val();
$.ajax({
type: "POST",
url:"ajax/login.php",
dataType: "json",
data: {"username": username, "password": password},
success: function(rt){
swal("Information", rt.Text, types[rt.Code]);
if (rt.Code == 200) location.href = "home.php";
}
});
});
KODLAR : (AJAX LOGİN SAYFASI )
$query = mysqli_query($connect, "SELECT * FROM data_users WHERE username = '$username' AND password = '$password'");
if (mysqli_affected_rows($connect)){
$fetch = mysqli_fetch_array($query);
$_SESSION['login'] = true;
$_SESSION['userid'] = $fetch['id'];
Output($Login['Success']);
}else{
Output($Login['Failed']);
}
KODLAR :LOGİNDEN SONRA YÖNLENEN HOME SAYFASI
include ('config.php');
$userid = $_SESSION['userid'];
$query = mysqli_query($connect, "SELECT * FROM data_users WHERE id = $userid");
$fetch = mysqli_fetch_array($query);
$btc = $fetch['btc'];
$oran2 = $fetch['btc_last'];
$username = $fetch['username'];
$name = $fetch['name'];
$tel = $fetch['tel'];
if (!isset($_SESSION['login'])){
echo " ";
exit();
}
?>