我使用PHP创建了一个简单的单词密码登录。密码存储在php文件中 - 我知道这不是大规模安全的,但我只想让人们无法漫步到该网站。登录表单提交按钮不起作用
为了测试密码的目的是密码
你可以看到,我有一个jQuery摇效果时,这是错误的。
我的问题:
为什么我的提交按钮不正确的密码在击中提交按钮工作,为什么不同的击球回报的行为,以提交按钮?
我的代码:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/vibrate.js"></script>
</head>
<body>
<!-- body content -->
<div class="wrapper">
<!-- container -->
<div class="container">
<div class="col-lg-12">
<div id="login" class="form-wrapper content-flood">
<form action='php/login.php' method="post" class="login-form" id="loginform">
<h3 class="text-center">Enter your password:</h3>
<input type="password" name="password">
<input type="button" name="Submit" id="submit_butt" value="Submit" formaction="php/login.php"/>
</form>
</div>
</div>
</div>
<!-- end container -->
</div>
<!-- end body content -->
<script type="text/javascript">
$(document).ready(function() {
$("#submit_butt").click(function() {
// configurations for the buzzing effect. Be careful not to make it too annoying!
var conf = {
frequency: 5000,
spread: 5,
duration: 600
};
/* do your AJAX call and processing here...
....
....
*/
// this is the call we make when the AJAX callback function indicates a login failure
$("#login").vibrate(conf);
// let's also display a notification
if($("#errormsg").text() == "")
$("#loginform").append('<p id="errormsg">Oops, wrong password!</p>');
// clear the fields to discourage brute forcing :)
$("#pwd").val("");
});
});
</script>
</body>
</html>
PHP:
<?php
// this password may come from any source.
// it's a variable for the sake of simplicity
$password = 'password';
if($_POST['password'] == $password){
$_SESSION["userid1"] = $id1;
header("Location: ../home.html"); // redirects
}else{
}
?>
的Javascript:
jQuery.fn.vibrate = function(conf) {
var config = jQuery.extend({
speed: 30,
duration: 2000,
frequency: 10000,
spread: 3
}, conf);
return this.each(function() {
var t = jQuery(this);
var vibrate = function() {
var topPos = Math.floor(Math.random() * config.spread) - ((config.spread - 1)/2);
var leftPos = Math.floor(Math.random() * config.spread) - ((config.spread - 1)/2);
var rotate = Math.floor(Math.random() * config.spread - (config.spread - 1)/2); // cheers to [email protected] for the rotation-idea
t.css({position: 'relative', left: leftPos +'px', top: topPos +'px', WebkitTransform: 'rotate(' +rotate +'deg)', WebkitTransform: 'rotate(0deg)'});
};
var doVibration = function() {
var vibrationInterval = setInterval(vibrate, config.speed);
var stopVibration = function() {
clearInterval(vibrationInterval);
t.css({position: 'static'});
};
setTimeout(stopVibration, config.duration);
};
/*
Mofication by Kishore - I am commenting out the following line as it calls the vibration function repeatedly.
We need to call it only once. So, instead I make a call to doVibration() directly.
*/
//setInterval(doVibration, config.frequency);
doVibration();
});
}
;
编辑:我离开'其他'在PHP空的借口jQuery处理错误?
我无法得到这个工作的JSFIDDLE,但这里是网站的行动(这也是一个测试版本)。
什么哟意思提交按钮不起作用,回报的行为不同。你能解释一下具体的问题吗? –
用正确的密码输入密码可让您进入该网站。用错误的密码输入时显示空白'login.php'。 做同样的事情,然后点击提交只是说,哎呀错误的密码 – lejimmie