Question:
PHP is unable to retrieve information via $_POST on my localhost but $_GET works?
Thomas Paine
2006-11-30 12:39:48 UTC
Let me preface this by saying that this is most certainly not a code issue but a config issue. I have been able to implement the code fine on my live server, this problem only occurs on my localhost.

I recently setup PHP and Apache (and mySQL) on my windows XP box. This is my first experience with PHP and it took me a long time to get everything working so bear with me. Everything was fine until I attempted to grab something using $_POST["mypostvar"] which returned an error saying "mypostvar" was not found while $_GET["mygetvar"] works fine.
The exact error is : "Notice: Undefined index: mypostvar".
I tried running var_dump($_POST);die; and it also returned nothing. I've tried all sorts of changes within php.ini including:
register_globals = "on"
gpc_order = "GPC"
I also tried the following things:
$_REQUEST["process"]
$HTTP_RAW_POST_DATA with always_populate_raw_post_data on

Version Info:
PHP Version 5.2.0RC6-dev
Apache Version:Apache/2.2.3 (Win32) PHP/5.2.0RC6-d
Five answers:
2006-11-30 14:59:52 UTC
Use single quotes as text qualifieres for the associative names in your $_POST array.



$_POST['var']



Double-quotes are not the same as single-quotes in PHP; as such, in certain configurations, depending on your magic quotes settings, you may get the unintended results you are seeing by using double-quotes.



Except when using the pseudofunctions echo or print, always use single-quotes as string qualifiers.



UPDATE:



After looking at this again, I think the problem is that your code is set up so that you are using the POST variable before those variables are defined.



You can simply do this:



$something = @$_POST['mypostvar'];



And you won't get the error messages any more.



Additionally, because you have turned register_globals on, you can always access the variable by its key:



$something = $mypostvar;



If none of that works, the PHP bugs section notes some issues with running PHP 4 off a Windows Apache install.
claypoole
2016-12-11 00:14:17 UTC
i think of I spoke back this question as quickly as until now.... interior the previous i might have mentioned comprehend/have confidence may be retrieved with incredibly some actual care and attempt. In that 2nd I greater effective than in all probability became into too lots related to regaining something I felt became into taken from me individually. a pair of years down the music and a few greater betrayals, enable downs and water below the bridge plus a transformation in occupation - i might could say i'm of the view on the tip of the day no longer something concerns...... I easily have constantly well known genuineness in a individual. without that - comprehend is impossible no count number what the condition. I easily have forgiven interior the previous - persevering with to have interplay - yet forgetting is the difficulty. interior the returned of the innovations there is often slightly concern that history repeats. according to hazard that's available to get some comprehend returned yet to restoration have confidence/comprehend in entirety - according to hazard no longer. Fractal I constantly locate your comments considerate & intelligently eloquent - and that i thank you. extra to Fractal: speaking from the attitude of training detachment (re: the no longer something concerns - no longer quitting lol in case you get me...) {{{don't be modest - enlightened remark is your distinctiveness'}}}
willy
2006-11-30 12:44:00 UTC
make sure that whatever is named 'mygetvar' looks like this:



Name="mygetvar"



i have found that having it like this:



ID="mygetvar"



does not work in PHP
travel4fun75
2006-12-03 01:11:53 UTC
ASIAWEBMEDIA TECHNOLOGIES Offshore Web Development & Software Development Company from India having more then 5 years of programming experience in PHP/MySQL, .Net, C# and Java/J2EE, with experienced professionals working.

You can hire a programmer / Web Developers/ Software Developers / Web Designers for all your Web & Software development requirements on monthly / hourly hiring basis.

Have a look at our online WEBSITE ( http://www.asiawebmedia.com )

We have extensive experience in Developing Ecommerce websites, Web applications, Dynamic Websites using PHP/MySQL,ASP.Net. Almost all of our professionals have minimum 2+ years of working experience. Have a look at our online portfolio at : http://www.asiawebmedia.com/portfolio.htm

If interested please contact at info@asiawebmedia.com or MSN IM at asiawebmedia@hotmail.com for additional information about this.



Thanks

Sagar

www.asiawebmedia.com
jake cigarâ„¢ is retired
2006-11-30 12:54:24 UTC
is it the form, and not the cgi?

METHOD="POST" with an appropriate encoding too!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...