Accessing $_Post array

Hello

I am submitting a form to a page for processing and I am having issues accessing the $_Post array.

When I do


echo print_r ($_POST);	

I see this

Array ( [owner] => Array ( [0] => me ) [dob] => 2011-08-21 [XX] => aaaa [YY => asdas [registeredName] => Array ( [0] => norman ) [sex] => Array ( [0] => M ) [Age] => Array ( [0] => 42 ) [submit] => submit )

But when I try to access sex for example using this


$sex = mysql_real_escape_string ($_REQUEST['sex']);

echo print_r ($sex);

I get nothing

Any ideas?

You should be using $_POST[‘sex’] not $_REQUEST

I did try this as well:


$sex = mysql_real_escape_string ($_POST['sex']);

And all I see then is a 1 suggesting it is some form of resource being returned, so I then tried:


echo print_r ($sex , 1);

Which printed nothing at all…

I am sure I am missing something obvious

Hi there,

If I may ask, what are you using to allow your users to select their gender? Is it a menu or a radio or something else? If you can control the value that gets passed to your scripts, then just reference them directly without using mysql_real_escape_string. You usually want to use that function if you can’t control in information being passed, you should be able to control the options that gender will give you and therefor really don’t need that function.

Hope this helps.

Hi.

We use mysql_real_escape_string by default when parsing data being posted to any of our pages to avoid the possibility of SQL injection, which we have actually had happen on several occassions.

Even removing the mysql_real_escape_string element of the code seems to have no effect…

I am at a loss now as it should be a relatively simple task

Can you post your whole code so we can see it all at the same time to make it easier? remember to use tags

Sponsor our Newsletter | Privacy Policy | Terms of Service