Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-2006, 09:23 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default $_POST and $_GET

While working on one server and connecting to a URL such as myscript.php?var=this I can use code like this:

PHP Code:
<?
echo $var// Echos this
?>
and it works fine. However, on another server if I put the same code and same URL syntax I get nothing. What is wrong on the second server?
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-14-2006, 04:00 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,817
Last Blog:
Passwords
Credits: 52
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John
Default

nothing is wrong with the second server other than it is more secure with its registered globals. If you have access to the php.ini find this line

register_globals =

and change it to either on or off depending on what it is set as now...


But either way this should work:
PHP Code:
<?
echo $_GET['var']; // Echos this
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-15-2006, 11:39 AM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Credits: 0
Rep Power: 12
NeedHelp is on a distinguished road
Default

I don't have access to the php.ini.
So there is no way to make those variables global? I have to use $_GET['var']? Is post the same $_POST['var']?
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-15-2006, 12:01 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,817
Last Blog:
Passwords
Credits: 52
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John
Default

its not a matter of global variables. gloval variables come into effect when you are working with seperate functions.

But yes you have to use $_GET['variable'] and $_POST['variable']. What i do a lot of times when im programing is right after the <?php set $_GET['variable'] equal to the reular variable so its easier to read.

PHP Code:
<?php
$variable 
$_GET['variable'];

//your code

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-15-2006, 12:32 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 26
Posts: 6,009
Last Blog:
SAP, ERP and EDI
Credits: 1
Rep Power: 20
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

You can always extract the data as well. Do this at the top of your scripts

PHP Code:
if(!empty($_GET)) extract($_GET);
if(!empty(
$_POST)) extract($_POST); 
Works as if register_globals was set to ON
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 07-17-2006, 06:12 AM
crocodile crocodile is offline
Newbie
 
Join Date: Jul 2006
Posts: 3
Credits: 0
Rep Power: 0
crocodile is on a distinguished road
Default

PHP Code:
<?php
    $var 
$_REQUEST['var']
?>
not a good choice
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 01:41 PM.

Contest Stats

Xav ........ 213.39
chili5 ........ 80.87
morefood2001 ........ 57.41
John ........ 52.33
gamiR ........ 40.76
MeTh0Dz|Reb0rn ........ 40.7
-MW- ........ 40
WingedPanther ........ 35.4
gaylo565 ........ 24
RyanTuosto ........ 23.34

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 68%

Ads