Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(document).ready(function(){
- $('#note').hide();
- $('form[name=login]').submit(function(){
- $('#note').slideUp();
- $.post('login.php',{username: $('[name=username]').val(), password: $('[name=password]').val()}, function(data){
- if(data.success){
- location.href = data.redirect;
- }else{
- $('#note').html(data.message).slideDown();
- }
- },'json');
- return false;
- });
- });
- </script>
- //--------------------------- login.php ----------------------------------
- <?php
- include ("scripts/database.php");
- session_start();
- $username = mysql_real_escape_string($_POST['username']);
- $password = mysql_real_escape_string($_POST['password']);
- $query = new query("SELECT * FROM admin WHERE Username ='$username' and Password='$password' LIMIT 1");
- $rows = $query->rows();
- if ($rows == 1) {
- $data['success'] = true;
- $_SESSION['adminID'] = $result['ID'];
- $data['redirect'] = '/OGBI/admin/index.php';
- //header("location:/OGBI/admin/");
- }else{
- $data['success'] = false;
- $data['message']="Invalid Username and Password !";
- }
- echo json_encode($data);
- ?>
Add Comment
Please, Sign In to add comment