我正在使用Screets Wordpress Sessions插件,它工作得非常好。我遇到的问题是,我将通过不同的表格等管理我的网站用户,而不是 wordpress。我的注册表单正在工作,它是否会发送确认电子邮件以阻止垃圾邮件。我遇到的问题是我的简单形式:
mysql_connect("localhost", "%username%", "%password%") or die(mysql_error()); // Connect to database server(localhost) with username and password.
mysql_select_db("%database%") or die(mysql_error()); // Select registration database.
if(isset($_POST['name']) && !empty($_POST['name']) AND isset($_POST['password']) && !empty($_POST['password']) AND isset($_POST['name']) && !empty($_POST['name'])){
$username = mysql_escape_string($_POST['name']);
$password = mysql_escape_string(md5($_POST['password']));
$search = mysql_query("SELECT username, password, active FROM %table% WHERE username='".$username."' AND password='".$password."' AND active='1'") or die(mysql_error());
$match = mysql_num_rows($search);
if($match = 1){
$msg = 'Login Complete! Thanks';
//$email = $row['EmailAddress'];
//;
//$_SESSION['EmailAddress'] = $email;
//$_SESSION['LoggedIn'] = 1;
$session->set_userdata( 'username', $username);
header ("Location: /");
}else{
$msg = 'Login Failed!<br /> Please make sure that you enter the correct details and that you have activated your account.';
}
}
?>
<!-- stop PHP Code -->
<!-- title and description -->
<h2>Login Form</h2>
<p>Please enter your name and password to login</p>
<?php
if(isset($msg)){ // Check if $msg is not empty
echo '<div class="statusmsg">'.$msg.'</div>'; // Display our message and add a div around it with the class statusmsg
} ?>
<!-- start sign up form -->
<form action="" method="post">
<label for="name">Username:</label>
<input type="text" name="name" value="" />
<label for="password">Password:</label>
<input type="password" name="password" value="" />
<input type="submit" class="submit_button" value="login" />
</form>
自动重定向到我的 wordpress 登录名,这不是我想要的。之前有人告诉我使用 wp_users,但我真的不想使用那个或插件。有什么想法可以让它按我需要的方式工作吗?
编辑:为了更好地澄清这个问题,任何点击提交的人都会被重定向到 wp-login.php。该页面甚至没有按照我的 SQL 连接来检查并实际创建会话。有任何想法吗?