JQuery 投稿で投稿ページを作成しようとしていますが、何らかの理由で投稿ボタンを押すと、同じページにリダイレクトされて何もしません。ここで何が欠けているのかわかりません。
私が望むのは、ログインすると別のページに移動するlogged-in.php
ことだけです。
ページ
<form class="form-2" action="./" method='post' autocomplete="off">
<h1><span class="log-in" style="font-size: 20px; margin-bottom: 25px;">Log in</span><span class="inner"></span></h1><br>
<p class="float">
<label for="username"> <i class="icon-fixed-width icon-user" style="font-size:15px;"></i>Username</label>
<input type="text" name="username" placeholder="Username or email" id="email" >
</p>
<p class="float">
<label for="password"><i class="icon-lock" style="font-size: 15px;"></i>Password</label>
<input type="password" name="password" placeholder="Password" class="showpassword" id="passwd">
</p><br>
<br>
<p class="clearfix">
<div class="register">Don't have credentials? Please <a href="./register.php">Register</a>.
<input type="submit" onclick="users_login();" name="submit" value="Submit">
</div>
</p>
</form>
<div class="_fields" align="left" id="login_status"></div><br clear="all">
JS ( users_login() )
function users_login()
{
var vpb_email = $("#email").val();
var vpb_passwd = $("#passwd").val();
if(vpb_email == "")
{
$("#login_status").html('<div class="info">Please enter your account email address to proceed.</div>');
$("#email").focus();
}
else if(vpb_passwd == "")
{
$("#login_status").html('<div class="info">Please enter your account password to go.</div>');
$("#passwd").focus();
}
else
{
alert("Inside the Ajax Validator: " + vpb_email + " Password " + vpb_passwd);
var dataString = 'email=' + vpb_email + '&passwd=' + vpb_passwd + '&page=users_login';
$.ajax({
type: "POST",
url: "save_details.php",
data: dataString,
cache: false,
beforeSend: function()
{
$("#login_status").html('<br clear="all"><br clear="all"><div align="left"><font style="font-family:Verdana, Geneva, sans-serif; font-size:15px; color:black;">Please wait</font> <img src="images/loadings.gif" alt="Loading...." align="absmiddle" title="Loading...."/></div><br clear="all">');
},
complete: function(){
},
success: function(response)
{
var response_brought = response.indexOf('login_process_completed_successfully=yes');
if (response_brought != -1)
{
$("#login_status").html('');
window.location.replace(response);
}
else
{
$("#login_status").fadeIn(1000).html(response);
}
}
});
}
}
PHP (save_details.php)
$user_email = trim(strip_tags($_POST['email']));
$user_password = trim(strip_tags($_POST['passwd']));
$encrypted_md5_password = md5($user_password);
$validate_user_information = mysql_query("select * from `signup_and_login_table` where `email` = '".mysql_real_escape_string($user_email)."' and `password` = '".mysql_real_escape_string($encrypted_md5_password)."'");
if(mysql_num_rows($validate_user_information) == 1)
{
$get_user_information = mysql_fetch_array($validate_user_information);
$_SESSION["VALID_USER_ID"] = $user_email;
$_SESSION["USER_FULLNAME"] = strip_tags($get_user_information["firstname"].' '.$get_user_information["lastname"]);
echo 'index.php?uid='.$_SESSION["USER_FULLNAME"].'&';
echo 'login_process_completed_successfully=yes';
}
else
{
echo '<br><div class="info">Sorry, you have provided incorrect information. Please enter correct user information to proceed. Thanks.</div><br>';
}
ありがとう。