Ajax navigation menu (code source)
js File to loading content via a menu, without refresh page using Ajax
Tutorial,Open source,News
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="css/style.css" media="screen" type="text/css" />
<script src=" https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="js/app.js"></script>
<head>
<meta charset="utf-8">
<title>Tuto4free Login</title>
</head>
<body>
<div id="login-form">
<h3>Tuto4free</h3>
<fieldset>
<form action="login.php">
<input type="email" id="Email" required placeholder="Email">
<input type="password" id="password" required placeholder="Password">
<input type="submit" id="Log_btn" value="Login">
<footer>
<div id="err"></div>
<p><span class="info">?</span><a href="http://www.tuto4free.com">Lost my password</a></p>
</footer>
</form>
</fieldset>
</div>
</body>
</html>
</body>
</html>
<?php
$pdo = new PDO('mysql:host=localhost;dbname=login', 'root','');
$SQL="SELECT * FROM `user` where email=? and Password=? ";
$req = $pdo->prepare($SQL);
$req->execute(array($_POST['username'],md5($_POST['password'])));
$res=$req->fetchAll();
if(count($res)==1)
{
echo "true";
}
else
{
echo "false";
}
$(document).ready(function(){
$("#Log_btn").click(function(){
username=$("#Email").val();
password=$("#password").val();
$.ajax({
type: "POST",
url: "login.php",
data: "username="+username+"&password="+password,
success: function(html){
if(html=='true')
{
$("#login-form").fadeOut();
}
else
{
$("#err").html("Wrong username or password");
}
},
beforeSend:function()
{
$("#err").html("Loading...")
}
});
return false;
});
});
public Tuple<string, int> Getinfo()
{
return Tuple.Create("Mouhcin", 24);
}
Copyright © 2014 Tuto4free | All Rights Reserved.
Design By Templateclue