Hi, i am having problems with using superglobals. I have been trying to use the $_GET and $_POST superglobals but no matter which one i use, it doesn't print out anything. It doesn't print out what i am trying to reach from a form. Is it something to do with my php.ini file? I have read somewhere that it is something to do with the register_global s part but am still not sure. Is there something i should do to enable these superglobals? Any help would be much appreciated, Thanks Chris
$_GET and $_POST superglobals are empty, but shouldn't be
Collapse
X
-
Tags: None
-
Heya, Chris. Welcome to TSDN!
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
$_GET and $_POST will only contain values if you are sending GET or POST variables, respectively.
To populate $_GET, you will need to append your variables to the query string. For example:
If you then call this code in script.php:Code:http://localhost/path/to/your/script.php?variable=value
[code=php]
print_r($_GET);
[/code]
You will see this:
Populating $_POST generally requires submitting a form.Code:Array ( [variable] => value )
For more information, have a look at this document.Comment
-
Comment
-
Hi yea sorry,
On my HTML page my code is . . .
[code=html]
<form action="calcula te.php" method="POST">
<p><strong> Input First Integer: </strong></p>
<input type="text" name="Integer_o ne">
<p><input type="submit" value="send"/></p>
</form>
[/code]
Then linked from this is a php document with the following code . . . .
[code=php]
<?php
echo $_POST['Integer_one'];
?>
[/code]Comment
-
Hi.Originally posted by chrispclayHi yea sorry,
On my HTML page my code is . . .
[code=html]
<form action="calcula te.php" method="POST">
<p><strong> Input First Integer: </strong></p>
<input type="text" name="Integer_o ne">
<p><input type="submit" value="send"/></p>
</form>
[/code]
Then linked from this is a php document with the following code . . . .
[code=php]
<?php
echo $_POST['Integer_one'];
?>
[/code]
I see no problem with that code. Under normal circumstances that code should print out the value you entered in the <input> box called 'Integer_one'.
That is, of course, assuming that the PHP code is in the file called 'calculate.php' .
If this isn't working... Are you sure you are not receiving any errors? Check out this thread to be absolutely sure.Comment
Comment