Problem with variables not posting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jhorra
Forum Newbie
Posts: 24
Joined: Mon Aug 18, 2003 1:00 am

Problem with variables not posting

Post by Jhorra »

I have taken out of the page the core code that is being used to test on a seperate page

Code: Select all

<form action='message_test.php' method='post'>
                <input type='hidden' name='mode' value='messages'>
                <input type='hidden' name='act' value='mes_list'>
                <input type='hidden' name='refer' value='inbox'>
                <input type='hidden' name='pro' value=''>

                <input type="checkbox" name="mes_id[]" value="17595" /></td><td>&nbsp</td><td><a href='index.php?mode=people_card&p_id=4'>pooh</a></td><td><a href='index.php?mode=messages&act=view_mes&mes_id=17595'>test</a>


           <input type='submit' value='Delete' onClick='this.form.pro.value="del"'>
           <input type='submit' value='Save' onClick='this.form.pro.value="sav"'>
           &nbsp&nbsp&nbsp&nbsp
           <input type='button' value='Compose Message' onClick='window.location="index.php?mode=messages&act=compose"'>&nbsp
           </form>
Every single value passes except for message id. I changed the name of the mes_id field to something I knew for a fact was not being used to see if it was being over written. If I post it back on this test page it passes the value, but when passed to index.php it never passes, no matter what it is named. Does anyone have any idea what could cause this?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Your passing it as an array. Are you retrieving it as such?
Jhorra
Forum Newbie
Posts: 24
Joined: Mon Aug 18, 2003 1:00 am

Post by Jhorra »

Burrito helped me fix it, thanks to those who looked.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

For the other 20 something thousand members we have here, would you mind posting your fix?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yes that would help.

And for those that find this later on via searching: a good way to discover what's going on with your sent variables is by using a function such as print_r() to investigate in place of any actual processing.

eg.

Code: Select all

<?php
   echo '<pre>';
        print_r ($_REQUEST);
   echo '</pre>';
?>
Works well for all superglobals.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Someone posted a little function once before that went kinda like this:

Code: Select all

<?php
/**
 * Prints a cleanly formatted variable dump
 * @access public
 * @param mixed $var The variable to investigate
 * @return void Outputs the formatted variable information
 */
function clean_dump($var)
{
    echo '<pre>';
    var_dump($var);
    echo '</pre>';
}
?>
You could always include this function in a core include file and then use it as needed for debugging or getting information.
Post Reply