473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

$_GET and $_POST superglobals are empty, but shouldn't be

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_globals part but am still not sure. Is there something i should do to enable these superglobals? Any help would be much appreciated, Thanks Chris
Aug 29 '07 #1
6 2597
abertay
10
would you mind if i ask you post your code here...

That way i can help you more quickly...
Aug 29 '07 #2
pbmods
5,821 Expert 4TB
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:
Expand|Select|Wrap|Line Numbers
  1. http://localhost/path/to/your/script.php?variable=value
  2.  
If you then call this code in script.php:
Expand|Select|Wrap|Line Numbers
  1. print_r($_GET);
  2.  
You will see this:
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [variable] => value
  4. )
  5.  
Populating $_POST generally requires submitting a form.

For more information, have a look at this document.
Aug 29 '07 #3
MarkoKlacar
296 Expert 100+
What version on PHP are you using?
Can you post the begining of the <form>-tag and the PHP-code?
Aug 29 '07 #4
Hi yea sorry,

On my HTML page my code is . . .
Expand|Select|Wrap|Line Numbers
  1. <form action="calculate.php" method="POST">
  2.         <p><strong> Input First Integer: </strong></p>
  3.         <input type="text" name="Integer_one">
  4.         <p><input type="submit" value="send"/></p>
  5. </form>
  6.  
Then linked from this is a php document with the following code . . . .
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.         echo $_POST['Integer_one'];
  3. ?>
  4.  
Sep 2 '07 #5
pbmods
5,821 Expert 4TB
Heya, Chris.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Sep 2 '07 #6
Atli
5,058 Expert 4TB
Hi yea sorry,

On my HTML page my code is . . .
Expand|Select|Wrap|Line Numbers
  1. <form action="calculate.php" method="POST">
  2.         <p><strong> Input First Integer: </strong></p>
  3.         <input type="text" name="Integer_one">
  4.         <p><input type="submit" value="send"/></p>
  5. </form>
  6.  
Then linked from this is a php document with the following code . . . .
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.         echo $_POST['Integer_one'];
  3. ?>
  4.  
Hi.

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.
Sep 3 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Phil Powell | last post by:
I have an inherited class method that is required to *only* handle items from $_POST (and $_POST alone, for security reasons), for validation and action processing. Problem is that there is a...
4
by: Sjaakie Helderhorst | last post by:
Hi, I recently installed the latest Fedora Core 2 but have some troubles of which I'm not sure are PHP or Apache 2 related... apologies if this is the wrong group. ...
7
by: Dan | last post by:
I was trying to troubleshoot a login page that doesn't work - it keeps saying the login/password is missing - when my tracing discovered this peculiar behavior. register_globals is off, so at...
7
by: sketch | last post by:
I have one page that does 3 different things depending on $_GET: 1. It shows an index with items. 2. It shows an item with a form to submit an amount. 3. It confirms the amount. I was just...
3
by: janrom1 | last post by:
I have problem with _GET method. When I want to send information from formulars by _POST it works but if I want to do it by _GET it doesn't work. Where is the problem ? Should I put something into...
1
by: stephane | last post by:
I have a problem which must be in this : print" <script type='text/javascript'> document.location.replace('http://127.0.0.1/add_task.php?req_id={$maxValue}&tk_request_name={$req_name}');...
1
by: stephane | last post by:
I have a problem which must be in this : print" <script type='text/javascript'> document.location.replace('http://127.0.0.1/add_task.php?req_id={$maxValue}&tk_request_name={$req_name}');...
21
tpaine
by: tpaine | last post by:
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....
2
by: keeps21 | last post by:
I have a script that recieves an id number via the address bar when a link is clicked. ie . index.php?id=1 if the link was for the story whose ID is 1. My script checks if a user is logged in,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.