Title: Wp_logout problem
Last modified: August 21, 2016

---

# Wp_logout problem

 *  [Thomas Varghese](https://wordpress.org/support/users/thomasv1502/)
 * (@thomasv1502)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/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”> <?php
 *  if(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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Thomas Varghese](https://wordpress.org/support/users/thomasv1502/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/wp_logout-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
