Page 1 of 1

$_POST doesn´t exist

Posted: Mon Nov 14, 2011 1:53 pm
by cortazar11
Hello,

I am using the wamp package and after checking with "if (!isset($_POST['myselect,box'])) print "it does not exists!";"
it seems that the predefined variable S_POST doesn´t exist.
After checking the server (wamp) variables the only requested method shows is REQUEST_METHOD = GET.

I have been trying to sort this out uninstalling and installing but nothing.
In the while I can´t use this feature.

Is there someone with a idea what is about?

By the way, someone knows some tutorial about this issues?


Many thanks,

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 1:55 pm
by Celauran

Code: Select all

if (!isset($_POST['myselect,box'])) print "it does not exists!
What is this supposed to do? $_POST should always exist, even if it's empty.

Try this:

Code: Select all

echo (isset($_POST)) ? "POST exists" : "POST does not exist";

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 2:12 pm
by cortazar11
Yes, sorry POST exists.

So ,why I can´t process the $_POST,$_GET if I can process the rest of the commands of PHP.

My HTML form Is:

<!DOCTYPE html PUBLIC "-//W3C//DTD/XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml11 ... tional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>A Web Page</title>
</head>
<body>

<form action="process.php" method="post">

First Name: <input type="text" name="Fname"/>
Last Name: <input type="text" name="LName"/>
City: <input type="text" name="City"/>
State: <input type="text" name="State"/>

Message: <textarea name="Message" cols="30" rows="5"></textarea>

<input type="submit" name="submit" value="Submit Data"/>

</form>

</body>
</html>

My process.php file is:
<?php

echo (isset($_POST)) ? "POST exists" : "POST does not exist";


echo $_POST["Fname"];
echo "Your First Name is: " . $_POST['FName'] . "<br/>";
echo "Your Last Name is: " . $_POST['LName'] . "<br/>";
echo "Your City is: " . $_POST['City'] . "<br/>";
echo "Your State is: " . $_POST['State'] . "<br/>";
echo "<br/>";
echo "Your Message is: " . $_POST['Message'];

?>

and the output localhost/process.php is:

POST exists
( ! ) Notice: Undefined index: Fname in C:\webserver\www\process.php on line 6
Call Stack
# Time Memory Function Location
1 0.0011 367136 {main}( ) ..\process.php:0

( ! ) Notice: Undefined index: FName in C:\webserver\www\process.php on line 7
Call Stack
# Time Memory Function Location
1 0.0011 367136 {main}( ) ..\process.php:0
Your First Name is:

( ! ) Notice: Undefined index: LName in C:\webserver\www\process.php on line 8
Call Stack
# Time Memory Function Location
1 0.0011 367136 {main}( ) ..\process.php:0
Your Last Name is:

( ! ) Notice: Undefined index: City in C:\webserver\www\process.php on line 9
Call Stack
# Time Memory Function Location
1 0.0011 367136 {main}( ) ..\process.php:0
Your City is:

( ! ) Notice: Undefined index: State in C:\webserver\www\process.php on line 10
Call Stack
# Time Memory Function Location
1 0.0011 367136 {main}( ) ..\process.php:0
Your State is:


( ! ) Notice: Undefined index: Message in C:\webserver\www\process.php on line 12
Call Stack
# Time Memory Function Location
1 0.0011 367136 {main}( ) ..\process.php:0
Your Message is:

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 2:15 pm
by Celauran
cortazar11 wrote:and the output localhost/process.php is:
You're not pointing your browser to process.php are you?

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 2:20 pm
by cortazar11
Yes, the adress in the browser is:

localhost/process.php

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 2:22 pm
by Celauran
That wasn't my question. If your form is redirecting you there, that's fine. If you're pointing your browser there yourself, that's why you're getting the empty values. You need to point your browser to the page containing the form.

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 3:05 pm
by cortazar11
The url of the HTML form is: file:///C:/webserver/www/test.html

after submitting it the url of the browser is:file:///C:/webserver/www/process.php
with this output:
<?php

print_r($_POST);

echo (isset($_POST)) ? "POST exists" : "POST does not exist";


echo $_POST["Fname"];
echo "Your First Name is: " . $_POST['FName'] . "<br/>";
echo "Your Last Name is: " . $_POST['LName'] . "<br/>";
echo "Your City is: " . $_POST['City'] . "<br/>";
echo "Your State is: " . $_POST['State'] . "<br/>";
echo "<br/>";
echo "Your Message is: " . $_POST['Message'];

?>

so I supposed that to retrieve the processed code I needed to look in the name of the server: localhost/process.php

Is it wrong all this?

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 3:07 pm
by Celauran
Pointing your browser to the process page will never show you anything because it depends on a form having been posted to it.

What do you mean by 'retrieve the processed code'? What is it you're trying to do?

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 3:37 pm
by cortazar11
I am pointing my browser to the page containing my form C:\webserver\www\test.html

but after submitting it is not redirected to: localhost/process.php

instead it goes to C:/webserver/www/process.php

so, how could I do to make that submitting being redirected to the process page?

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 3:45 pm
by Celauran
Don't point your browser to C:\ anything. Point it to localhost/test.html

Re: $_POST doesn´t exist

Posted: Mon Nov 14, 2011 3:58 pm
by cortazar11
Finally,
Thank you.

I have been stucked doing the wrong thing once and again.

Many thanks