Wp_logout problem
-
I am using the wp_logout() on the onclick property of anchor tag but when i refresh the page it automatically gets executed and logs out the user.The following is my code
<table>
<tr>
<td>
<form method=”post” action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” name=”aform” target=”_top” >
Login Id :<input type=”text” name=”log” id=”log” value=”” />
Password :<input type=”password” name=”pwd” id=”pwd” value=”” />
<input type=”submit” name=”login” value=”Login” />
<input type=”reset” name=”login” value=”Reset” />
</form>
</td>
<td width=”100px” align=”right”>
<label>Welcome : </label></td>
<td width=”150px”> <?phpif(is_user_logged_in())
{
$current_user = wp_get_current_user();
echo $current_user->user_login;
}
else
{
echo “Guest”;
}
?>
</td>
<td width=”100px” align=”right”>
“>Logout
</td></tr>
</table></div>
<?php global $wpdb;
if($_POST[‘log’] != “” && $_POST[‘pwd’] != “”)
{
$res=$wpdb->get_results(‘select * from login where uname=”‘.$_POST[‘log’].'” and pass=”‘.$_POST[‘pwd’].'”‘);if($wpdb->num_rows)
{
foreach($res as $result)
{
$credentials = array();
$credentials[‘user_login’] = $result->uname;
$credentials[‘user_password’] = $result->pass;
$credentials[‘remember’] = true;
$user = wp_signon( $credentials, true );
wp_redirect( home_url() ); exit;
}
wp_redirect( home_url() ); exit;
}
} ?>
The topic ‘Wp_logout problem’ is closed to new replies.