私のサイトでは、インデックス ページからログインすると、サインイン機能が正常に動作します。しかし、当サイトのインデックスページ以外からログインするとログインできません。
http://domain.com/mysite/index.php
このページからログインすると、機能は正常に動作し、ログイン後に次のようなページが表示されます
サイトの他のページからログインすると、正常に動作せず、ページが http://mysite.com/samplefolder/detailpage.php?pollid=2&chid=2として表示されます
Signin.php
<?php
include("jalert.php");
if (array_key_exists("login", $_GET)) {
$oauth_provider = $_GET['oauth_provider']; if ($oauth_provider == 'twitter') { header("場所: login-twitter.php"); } } ?>
<script type="text/javascript">
$(document).ready(function() {
$("#new_user_session_ajax").submit(function(e){
e.preventDefault();
var email = $('#userid').val();
var password = $('#signin_password').val();
var remember = $('#user_session_remember_me').val();
$.ajax({
type: "POST",
url: "ajaxlogin.php",
data: "userid="+email+"&password1="+password+"&rememberme="+remember+""
}).done(function( msg ) {
if(msg)
{
$('#error').html(msg);
}
else
{
window.location.href="index.php";
}
});
});
});
</script>
<form accept-charset="UTF-8" action="" name="login" onsubmit="return checkreg();" class="no_scroll_animation validate no_bump ajax" id="new_user_session_ajax" method="post">
<input name="utf8" type="hidden" value="">
<input name="authenticity_token" type="hidden" value="yRcKhChgROcxunh7A7zRQVroShpYbO6e6PaAO4JHUtg=">
</div>
<input id="after_url" name="redirect_after_login" type="hidden" value="/">
<li class="remember_me clear">
<input name="user_session[remember_me]" type="hidden" value="0">
<input checked="checked" id="external_remember_me_popup" name="remember_me" type="checkbox" value="1">
<label for="external_remember_me_popup">Remember me</label>
<h5>Sign in with email</h5>
<li><input autocapitalize="off" class="validate validate_required validate_email placeholder" id="userid" name="userid" value="Email Address"
onfocus="if(this.value == 'Email Address') {this.value=''}" onblur="if(this.value == ''){this.value ='Email Address'}" title="email" type="email" value=""></li>
<li><input autocapitalize="off" class="validate validate_required placeholder" id="signin_password" name="password1" value="Password"
onfocus="if(this.value == 'Password') {this.value='';this.type='password'}" onblur="if(this.value == ''){this.value ='Password';this.type ='text'}" type="text" validate:message="Please enter your password" value=""></li><li class="last">
<input class="button" name="login" type="submit" value="Login" >
<div class="keepmeloggedin"><input name="rememberme" type="hidden" value="remember me"><input checked="checked" id="user_session_remember_me" value="remember me" name="rememberme" type="checkbox" value="1"> Remember me</div><div class="forgotPassword">
<a class="forget_pass" href="forgot_password.php" id="forgotPasswordLink" rel="nofollow">Forgot password?</a></div></li></ul></div></form>
Ajaxlogin.php
<?php
include("classes.php");
$jeob = new EF_Sql();
$email= $_POST['userid'];
$password= $_POST['password1'];
$papas=base64_encode($password);
$check = $_POST['rememberme'];
$tablename="user_record";
$select_qry = $jeob->SqlQuery("SELECT * FROM ".$jeob->dbprefix.$tablename." WHERE email ='$email' AND password ='$papas' AND active_link='1' ");
$kiss="SELECT * FROM ".$jeob->dbprefix.$tablename." WHERE email ='$email' AND password ='$papas'";
if($jeob->SqlRows($select_qry) == "0"){
echo "Invalid Username and Password";
} else {
if($check) {
setcookie("username", $email, time() + 3600); // Sets the cookie username
}
$getuser = $jeob->SqlFetch($select_qry);
$_SESSION['userid'] = $getuser['user_id'];
$_SESSION['oauth_provider'] = "normal";
$_SESSION['email'] = $getuser['email'];
}
?>