Title: Option selected when $_POST==value
Last modified: August 21, 2016

---

# Option selected when $_POST==value

 *  [eMink](https://wordpress.org/support/users/emink/)
 * (@emink)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/option-selected-when-_postvalue/)
 * Hello,
 * first of all, thank you for creating a plugin like Contact Form 7 and making 
   it for free. It’s really useful and easy to use!
 * But now I have a problem. The thing is that I have a page with plan prices. Each
   plan has a submit button (inside a form) so I can get the value I want through
   $_POST. The action of this simple form is redirected to one of the Contact Form
   7 forms I prepared. Using the plugin “Allow PHP in posts” I could show the $_POST
   value, and see everything was working.
 * After that I wanted to edit the select.php file, so I could match the value I
   wanted to select with the one from $_POST, so I made a conditional looking if
   the value from $_POST was empty, so it will show the normal form or not. But 
   after that, I realised I couldn’t match the value that I wanted to be selected
   with the value from $_POST. And right here is my problem.
 * I hope you could help me, so I’ve been looking for this problem for a few days.
 *     ```
       if ( empty($_POST["pla"]) ){
       		   $html .= sprintf( '<option %1$s>%2$s</option>',
       			   $item_atts, esc_html( $label ) );
               }else{
                  $html .= sprintf('<option ');
   
                  if ( ($_POST["pla"]) == '?what do I put here?') {
                      $html .= sprintf (' selected ');
                  }
   
                  $html .= sprintf( '%1$s>%2$s</option>',
       			   $item_atts, esc_html( $label ) );
               }
       ```
   
 * [http://wordpress.org/plugins/contact-form-7/](http://wordpress.org/plugins/contact-form-7/)

The topic ‘Option selected when $_POST==value’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * ["selected"](https://wordpress.org/support/topic-tag/selected/)
 * [option](https://wordpress.org/support/topic-tag/option/)
 * [select](https://wordpress.org/support/topic-tag/select/)

 * 0 replies
 * 1 participant
 * Last reply from: [eMink](https://wordpress.org/support/users/emink/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/option-selected-when-_postvalue/)
 * Status: not resolved