请查看以下代码,这是针对我的网站前端通过wordpress而没有使用wordpress平台,但登录页面有问题。
<?php
global $wpdb;
$err = '';
$success = '';
if(isset($_POST['task']) && $_POST['task'] == 'login' )
{
//We shall SQL escape all inputs to avoid sql injection.
$username = $wpdb->escape($_POST['log']);
$password = $wpdb->escape($_POST['pwd']);
$remember = $wpdb->escape($_POST['remember']);
if( $username == "" || $password == "" ) {
$err = 'Please don\'t leave the required field.';
} else {
$user_data = array();
$user_data['user_login'] = $username;
$user_data['user_password'] = $password;
$user_data['remember'] = $remember;
$user = wp_signon( $user_data, false );
if ( is_wp_error($user) ) {
$err = $user->get_error_message();
exit();
} else {
wp_set_current_user( $user->ID, $username );
do_action('set_current_user');
echo '<script type="text/javascript">window.location='. get_bloginfo('url') .'</script>';
exit();
}
}
}
?>
这是用于登录的表格。
<form method="post">
<div class="message"><h2>Already have an account? Please login.</h2></div>
<p>
<?php
if( !empty($sucess) )
echo $sucess;
if( !empty($err) )
echo $err;
?>
</p>
<input type="text" name="log" value="" id="log" class="textbox" placeholder="Username"/>
<input type="password" name="pwd" value="" id="pwd" class="textbox" placeholder="Password"/>
<p><input type="submit" value="Login" class="button" />
<label><input type="checkbox" name="remember" value="true" /> Remember Me</label>
<input type="hidden" name="task" value="login" />
</form>
为什么我会收到以下信息:警告无法修改标题信息
我如何解决这个问题?