Title: Conditional page
Last modified: August 19, 2016

---

# Conditional page

 *  [thom667](https://wordpress.org/support/users/thom667/)
 * (@thom667)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/conditional-page-1/)
 * Hi.
 * I basically removed the default sidebar.php code and wrote my own, which resides
   in /wordpress/wp-content/themes/starkers/sidebar.php
 * Now, in the sidebar, I have a mailing list form whose ‘action’ file is called
   mlist.php which resides in /wordpress/mlist.php
 * i.e. <form action=”/wordpress/mlist.php” method=”post”>…
 * mlist.php takes the email address address inputted and decides whether or not
   to add it to a database and then gives appropriate output. But I want this output
   to blend in with my theme.
 * So say I create a page:
 *     ```
       <?php
       get_header();
       //CONDITIONAL STUFF GOES HERE
       get_sidebar();
       get_footer();
       ?>
       ```
   
 * I want mlist.php do the following
 *     ```
       if (email address successfully added)
       {
         output success message;
       }
       else
       {
         output error message;
       }
       ```
   
 * But I want the messages to appear where “//CONDITIONAL STUFF GOES HERE” is above.
   I tried creating separate php pages and then using header() to redirect but something
   went wrong. For example, I created the file /wordpress/wp-content/themes/starkers/
   invalid_email.php and used the following redirect code in mlist.php:
 *     ```
       header ("Location: ".TEMPLATEPATH."/invalid_email.php);
       ```
   
 * But this didn’t work and said that [http://127.0.0.1/usr/var/www/…/starkers/invalid_email.php](http://127.0.0.1/usr/var/www/…/starkers/invalid_email.php)
   didn’t exist. So obviously I don’t understand how wordpress structures these 
   redirects.
 * Another thing, is that creating a page for each output message seems like overkill
   for me. Is there a neater way to do what I want?
 * Sorry for the long post, thanks for reading.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [thom667](https://wordpress.org/support/users/thom667/)
 * (@thom667)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/conditional-page-1/#post-1159258)
 * OK, thought I’d just encompass it all into mlist.php.
 * mlist.php:
 *     ```
       <?php
   
       get_header();
   
       // Email validation
       // and database queries
       // go here,
       // along with conditional output
   
       get_sidebar ();
       get_footer ();
       ```
   
 * Now since I’m calling the get_*() functions, I’ll need to move mlist.php into
   the theme folder, yes? Well that’s what I did.
 * Then I opened up sidebar.php and changed my form to <form action=”mlist.php” 
   method=”post”> since mlist.php and sidebar.php reside in the same directory.
   
   This gave me an error when I submitted the form on my front page. So I changed
   it to action=”full/path/to/mlist.php”. Now I get an error ** “Call to undefined
   function get_header()”**. How do I get this to work?
 *  Thread Starter [thom667](https://wordpress.org/support/users/thom667/)
 * (@thom667)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/conditional-page-1/#post-1159316)
 * Solved.
 * Had to include wp-load.php.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Conditional page’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)

 * 2 replies
 * 1 participant
 * Last reply from: [thom667](https://wordpress.org/support/users/thom667/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/conditional-page-1/#post-1159316)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
