Title: help with php code inserted in header.php file
Last modified: August 19, 2016

---

# help with php code inserted in header.php file

 *  Resolved [tkm](https://wordpress.org/support/users/tkm/)
 * (@tkm)
 * [17 years ago](https://wordpress.org/support/topic/help-with-php-code-inserted-in-headerphp-file/)
 * Hi,
 * I’ve inserted the below php if statement code into the header.php file. The code
   checks to see if a user is logged in or not and then shows some text accordingly.
   For some reason the if part is not being recognised and else text is always being
   shown. I have this same php code in the index.php template file and it works 
   fine. So, it seems to be just an issue with the header.php file. Any help would
   be much appreciated!
 *     ```
       if(isset($HTTP_SESSION_VARS['user_ids']) &amp;&amp; $HTTP_SESSION_VARS['user_ids'] != "")
       {
         $user_ids = $HTTP_SESSION_VARS['user_ids'];
         $Query_user_log = mysql_query("select * from  wp_users where ID = '$user_ids'");
         $num_log = mysql_num_rows($Query_user_log);
         if($num_log > 0)
         {
         $result_log= mysql_fetch_array($Query_user_log);
         $user_name = $result_log['user_nicename'];
         }
         echo "<<em>output this text</em>> ";
         }
         else
         {
         echo "<<em>output this text instead</em>>";
         }
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [tkm](https://wordpress.org/support/users/tkm/)
 * (@tkm)
 * [17 years ago](https://wordpress.org/support/topic/help-with-php-code-inserted-in-headerphp-file/#post-1067225)
 * Hi guys,
 * I ended up findng a resolution after much searching online. Here is the resolution:
 * [http://blog.ginchen.de/en/2008/08/15/session-variablen-in-wordpress/](http://blog.ginchen.de/en/2008/08/15/session-variablen-in-wordpress/)

Viewing 1 replies (of 1 total)

The topic ‘help with php code inserted in header.php file’ is closed to new replies.

## Tags

 * [header](https://wordpress.org/support/topic-tag/header/)
 * [if statement](https://wordpress.org/support/topic-tag/if-statement/)
 * [index](https://wordpress.org/support/topic-tag/index/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [tkm](https://wordpress.org/support/users/tkm/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/help-with-php-code-inserted-in-headerphp-file/#post-1067225)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
