A million ways. It is not safe to store the password in the code of the page itself, because it will be transferred to the client and, if desired, it will be decoded two times. I suggest you implement through AJAX, the meaning is as follows:
- when you press a button, say, "input", a request is sent to the server
- if server is not available or response from server "error" show div
- if the response from the server is "accept" then form.submit ();
The code may be:
$('a').click(function(e){ e.preventDefault(); $.ajax({ type: 'POST', url: 'login-ajax.php', success: function(response){ if (response == 'accept') { $('#do').submit(); } else { $('div').fadeIn(400); } }, error: function(response){ $('div').fadeIn(400); } }); });
Fiddle: http://jsfiddle.net/CxrVg/
Well, in PHP, actually something like this:
<?php $pass = ''; if (isset($_POST['pass']) { $pass = $_POST['pass']; } /.. обезопасить входящие данные ../ /.. сверить с базой ../ if ( %ПАРОЛЬ СОВПАЛ% ) { die('accept'); } else { die('error'); } ?>