Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm new to wordpress but I really like this and I would love to write my applications inside of wordpress. However there are still many things to learn and after a while one can lose it's head, as I just did. I've been searching for a sollution the last 2 day's on a very simple problem. I want to reload an admin page and pass $_POST variables. Actually I want to write a little crm program inside the admin panel as it is nicely put away from the public (front) section.

Maybe this is not the right way to work, if it isn't please let me know.

The first problem I'm facing is that I can't seem to pass the $_POST variables naam and voornaam when reposting the page. As wordpress passes the page itself as a variable.

this is the simple code:

/** Step 2 (from text above). */
add_action( 'admin_menu', 'patientenbeheer' );

/** Step 1. */
function patientenbeheer() {
    add_menu_page(__('patientenbeheer'), __('patientenbeheer'),'manage_options', basename(__FILE__), 'patientenbeheer_options');
}      


/** Step 3. */
function patientenbeheer_options() {
    if ( !current_user_can( 'manage_options' ) )  {
    wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
?>
    <div class="wrap"> 
    <h2><?php _e('patientenbeheer'); ?></h2>

    <div id="saved"></div>   
    <form action="" method="post" enctype="multipart/form-data">   
    <p>naam: <input type="text" name="naam" value="" /> voornaam: <input type="text" name="vnaam" value="" /><br />    
    <input type="submit" value="Submit" />
    <?php
    if ( isset($_POST)) {
        if (! isset($_POST['vnaam'])){
            echo "<p> naam: ".$_POST['naam']." </p>";
        }elseif ( ! isset($_POST['naam'])){
            echo "<p> vnaam: ".$_POST['vnaam']." </p>";
        } else {
            echo "<p> beide </p>";
        }
    }
    ?>

    <p>
    </form>
    </div>       

reload returns this: ../wp-admin/admin.php?page=martial-patientenbeheer.php

if I change the form tag to this: I get: ../wp-admin/admin.php?naam=naam&vnaam=

the $_POST values are include but the link is missing the page: martial-patientenbeheer.php. It shoud reload to: ../wp-admin/admin.php?page=martial-patientenbeheer.php?naam=naam&vnaam=

Is this possible or is my working method wrong?

putting it more simply, I want to add text to my page each time variables are passed. Text being the info from a sql select query or fields to add a new patient.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

WordPress passes the page as GET but your form uses POST. The two are different things. POST data never shows up in the URL like this: /wp-admin/admin.php?page=martial-patientenbeheer.php?naam=naam&vnaam= It is sent in the headers.

Put var_dump($_POST) at the top of your callback and you should see your post data. You are looking for the data in the wrong place.

share|improve this answer
    
thank you so much! –  Martial Van den Bossche Aug 1 '13 at 20:02
    
If this solved the question please mark it as "Accepted". Look for the check mark on the left. –  s_ha_dum Aug 1 '13 at 20:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.