Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Eli

    (@scheeeli)

    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

    (@dicksontan)

    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

    (@dicksontan)

    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

    (@scheeeli)

    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

    (@dicksontan)

    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

    (@scheeeli)

    $_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

    (@dicksontan)

    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.