I have a login system that was working and now isn't. It seems to run the check on whether there is a username password, but upon submitting nothing happens. there is an access.php page that allows access to certain pages based on whether login has been done. that isn't passing through so I think something is wrong with the submit or the onLogin function but hopefully someone whos a pro can let me know. If you need to see the access or register page, let me know
THANKS!!
Here is my login page PHP
PHP Code:
<?php session_start(); ?>
<script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
$(document).ready(function() {
$("#loginform").validate({
rules: {
email: {
required: true,
email:true
},
password: {
required: true,
},
},
messages: {
password: "Please enter your password",
email: "Please enter a valid email address"
}
});
});
function OnLogin(){
var email = $('#email').val();
var password = $('#password').val();
if ( email != "" && password != "" ){
$.ajax({
url:'lib/login.php',
type:'POST',
data:"email=" + email + "&password=" + password,
async:false,
success: function(str){
if ( str.indexOf("SUCCESS") != -1 )
{
if ( $("#redirect").length > 0 && $("#redirect").val() != "" )
location.href = $("#redirect").val() + ".php";
else
location.reload();
return;
}
else
{
if ( str.indexOf("PWD") != -1 )
{
alert("Please input the correct password.");
$("#password").focus();
}
else if ( str.indexOf("UID") != -1 )
{
alert("Please input the correct email.");
$("#email").focus();
}
}
}
});
}
}
function OnRegister(){
location.href = "register.php";
}
function OnLogOut(){
$.ajax({
url:'lib/logout.php',
type:'POST',
data:"logout=1",
async:false,
success: function(str){
if ( str.indexOf("SUCCESS") != -1 )
{
location.reload();
return;
}
}
});
}
//]]>
</script>
<?php if( !isset($_SESSION['PHP_AUTH_USER']) ): ?>
<h1>User Login</h1>
<div id="login-form">
<form id="loginform" name="loginform" method="post" onsubmit="OnLogin();return false;">
<h3>Email</h3>
<input type="text" name="email" id="email" />
<h3>Password</h3>
<input type="password" name="password" id="password" />
<br />
<input type="submit" class="login button" src="images/login.jpg" />
<input type="button" class="register button" src="images/register.jpg" onclick="OnRegister()" />
</form>
</div>
<?php else:?>
<p>Thanks <strong><?=$user_name?></strong>, You are now logged in.</p>
<p style="text-align:center"><input type="button" class="button" onclick="OnLogOut()" value="logout" /></p>
<?php endif;?>
Bookmarks