我在 wordpress 网站上创建了一个登录表单,该表单将允许用户访问仅限会员的内容。我有三个功能login()
resetPassword()
和register()
.
在我添加了第三个函数之前,login()
和表单都可以正常工作,然后根本不会提交任何表单。resetPassword()
register()
如果我删除该register()
功能,那么其他表单将再次开始工作。此外,如果我将其他功能放在他们自己的<script>
标签中,那么它们会按预期工作,但该register()
功能仍然无法正常工作。
我一遍又一遍地查看代码,并尝试将其放置在不同的区域......我不确定是什么导致了问题。以前有没有人发生过这种情况?我如何解决它?
<script type="text/javascript">
function login()
{
var email = document.getElementById("LoginUName").value;
var pword = document.getElementById("LoginPWord").value;
var xmlhttp;
if (window.XMLHttpRequest)xmlhttp=new XMLHttpRequest();
else xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.onreadystatechange=function(){document.getElementById('LoginScreen').innerHTML=xmlhttp.responseText;}
xmlhttp.open('GET','login.php?EMail='+email+'&PWord='+pword,true);
xmlhttp.send();
}
function resetPassword()
{
var email = document.getElementById("ResetEMail").value;
var xmlhttp;
if (window.XMLHttpRequest)xmlhttp=new XMLHttpRequest();
else xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.onreadystatechange=function(){document.getElementById('LoginScreen').innerHTML=xmlhttp.responseText;}
xmlhttp.open('GET','passwordReset.php?EMail='+email,true);
xmlhttp.send();
}
function register()
{
var firstname = document.getElementById("RegisterFirstName").value;
var lastname = document.getElementById("RegisterLastName").value;
var email = document.getElementById("RegisterEMail").value;
var pword = document.getElementById("RegisterPWord").value;
var xmlhttp;
if (window.XMLHttpRequest)xmlhttp=new XMLHttpRequest();
else xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.onreadystatechange=function(){document.getElementById('LoginScreen').innerHTML=xmlhttp.responseText;}
xmlhttp.open('GET','register.php?FirstName='+firstname+'&LastName='+lastname+'&EMail='+email'&PWord='+pword,true);
xmlhttp.send();
}
</script>
<div id="LoginScreen">
<h1>Welcome to ****.</h1><br>
<h2>Please login or register below:</h2><br>
<form action="javascript: login()" method="get">
<ul>
<li>
<h3>Username: </h3><input type="email" id="LoginUName" name="LoginUName" placeholder="Email address" />
</li>
<li>
<h3>Password: </h3><input type="password" id="LoginPWord" name="LoginPWord" placeholder="Password"/>
</li>
</ul>
<input type="submit" value="Login"/>
</form>
<br><hr><br>
<form action="javascript: resetPassword()" method="get">
<h2>Forgot your password?</h2><br>
Email address: <input type="email" id="ResetEMail" name="ResetEMail" placeholder="Email address" /> <input type="submit" value="Reset" />
</form>
<br><hr><br>
<form action="javascript: register()" method="get">
<h2>Register new user:</h2><br>
<ul>
<li>
<h3>First Name: </h3><input type="text" id="RegisterFirstName" name="RegisterFirstName" placeholder="First Name" />
</li>
<li>
<h3>Last Name: </h3><input type="text" id="RegisterLastName" name="RegisterLastName" placeholder="Last Name" />
</li>
<li>
<h3>Email: </h3><input type="email" id="RegisterEMail" name="RegisterEMail" placeholder="email address" />
</li>
<li>
<h3>Password: </h3><input type="password" id="RegisterPWord" name="RegisterPWord" placeholder="Password" />
</li>
</ul>
<input type="submit" value="Register"/>
</form>