Title: Using user&#039;s input data
Last modified: August 21, 2016

---

# Using user's input data

 *  Resolved [DicksonTan](https://wordpress.org/support/users/dicksontan/)
 * (@dicksontan)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/)
 * Hi,
 * IS there anyway for me to use user’s input (eg : drop-down menu selection) to
   do an sql query?
 * Thanks!
    Dickson
 * [https://wordpress.org/plugins/elisqlreports/](https://wordpress.org/plugins/elisqlreports/)

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

 *  Plugin Author [Eli](https://wordpress.org/support/users/scheeeli/)
 * (@scheeeli)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984952)
 * Yes, just make a form on your page that you have the report on like this:
 *     ```
       <form method="POST">
       <select name="choice"><option value="...">...</option></select>
       </form>
       ```
   
 * and then add the POST variable to the query like this:
 * `SELECT * FROM table WHERE field = '<?php $_POST[choice]; ?>'`
 *  Thread Starter [DicksonTan](https://wordpress.org/support/users/dicksontan/)
 * (@dicksontan)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984983)
 * Thank You!
 * I’ve use the following codes in my template, it doesn’t seem to retrieve anything,
   but works only if I hard coded the ‘choice’.
 * Could it be my syntax error here? I tried both $_POST[‘choice’] and $_POST[choice]..
 * <?php
    $str = “SELECT * FROM wp_cf7dbplugin_submits where field_name = “. $_POST[‘
   choice’];
 * $res = $wpdb->get_results( $str );
    foreach ( $res as $a ) {echo $a->field_name.”
   = “. $a->field_value.”“;} ?>
 * Dickson
 *  Thread Starter [DicksonTan](https://wordpress.org/support/users/dicksontan/)
 * (@dicksontan)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984984)
 * Ok I got it!
 * It should be
    <?php $str = “SELECT * FROM wp_cf7dbplugin_submits where field_name
   = ‘”. $_POST[‘choice’].”‘”;
 * …?>
 * Thank You!
    Dickson
 *  Plugin Author [Eli](https://wordpress.org/support/users/scheeeli/)
 * (@scheeeli)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984985)
 * Ok, I’m a little confused. Are you using my plugin to display the query or are
   you writing your own PHP?
 * The example I give in my last post was to be used within my plugin.
 * The code you have shown here looks like your own custom PHP.
 * … just got you second post as I was writing this. I guess you figured it out.
   🙂
 * Aloha, Eli
 *  Thread Starter [DicksonTan](https://wordpress.org/support/users/dicksontan/)
 * (@dicksontan)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984986)
 * Initially I tried using
 * SELECT * FROM wp_cf7dbplugin_submits WHERE field_name = “<?php $_POST[‘choice’];?
   >”
 * in your plugin, and use the shortcode over the page with user input. However 
   cant seem to get the input working…
    So I tried putting it in the template page
   of php..
 * Is that the correct way of sending input to the plugin?
 * 🙂
    Dickson
 *  Plugin Author [Eli](https://wordpress.org/support/users/scheeeli/)
 * (@scheeeli)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984987)
 * $_POST[‘choice’];
    the above is correct in PHP but in my plugin you can only 
   access the elements in global array without the quotes, like this: $_POST[choice];
 * If you give me the URL to the page where you are using my shortcode I’ll take
   a look and see if I can tell what’s wrong.
 *  Thread Starter [DicksonTan](https://wordpress.org/support/users/dicksontan/)
 * (@dicksontan)
 * [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984988)
 * Oh! I just figured out again..
    It should be SELECT * FROM wp_cf7dbplugin_submits
   WHERE field_value = ‘<?php $_POST[prdt]; ?>’
 * field_value 🙂
 * Thanks alot, its working now 😉
 * Dickson

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

The topic ‘Using user's input data’ is closed to new replies.

 * ![](https://ps.w.org/elisqlreports/assets/icon-256x256.png?rev=1231385)
 * [EZ SQL Reports Shortcode Widget and DB Backup](https://wordpress.org/plugins/elisqlreports/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elisqlreports/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elisqlreports/)
 * [Active Topics](https://wordpress.org/support/plugin/elisqlreports/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elisqlreports/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elisqlreports/reviews/)

## Tags

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

 * 7 replies
 * 2 participants
 * Last reply from: [DicksonTan](https://wordpress.org/support/users/dicksontan/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/using-users-input-data/#post-4984988)
 * Status: resolved