[PHP] Global Vars
I installed SuSE Linux 9.0 along with php. The flag below is turned off by default. I could not send any vars with a post or get form. I turned it one and all works well. The comments tell you not to turn it on because of possible security issues and to code around it. My question is how do you send vars and session var from page to page without it turned on? Any info would be a big help. Thanks for your time. ; You should do your best to write your scripts so that they do not require ; register_globals to be on; Using form variables as globals can easily lead ; to possible security problems, if the code is not very well thought of. register_globals = On Patrick Fowler Unix Admin/database Admin Wynit, Inc. 6847 Ellicott Drive East Syracuse, NY 13057 V (315)437-1086 x2172 F (315)437-0432
Re: [PHP] Global Vars
use $_POST['name_of_your_form_field'] or $_GET['name_of_your_form_field'] or $_REQUEST['name_of_your_form_field'] $_REQUEST contains $_GET, $_POST and $_COOKIE for server vars there is $_SERVER and $_ENV for environment vars $_SESSION is for session vars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Global Vars
[snip]My question is how do you send vars and session var from page to page without it turned on? Any info would be a big help. [/snip] rtfm, rtfa, stfw use $_POST or $_GET array http://www.php.net/variable -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Global Vars
$_GET['variable_name'] for GET variables and $_POST['variable_name'] for POST variables. Change the variable_name to whatever was in your form, for example the below variable name is cust_name input type=text name=cust_name For session it would be $_SESSION['session_name'] etc etc The above should get you going, but read up in the manual. Cheers, -Ryan On 3/4/2004 6:55:50 PM, Patrick Fowler ([EMAIL PROTECTED]) wrote: I installed SuSE Linux 9.0 along with php. The flag below is turned off by default. I could not send any vars with a post or get form. I turned it one and all works well. The comments tell you not to turn it on because of possible security issues and to code around it. My question is how do you send vars and session var from page to page without it turned on? Any info would be a big help. Thanks for your time. ; You should do your best to write your scripts so that they do not require ; register_globals to be on; Using form variables as globals can easily lead ; to possible security problems, if the code is not very well thought of. register_globals = On Patrick Fowler Unix Admin/database Admin Wynit, Inc. 6847 Ellicott Drive East Syracuse, NY 13057 V (315)437-1086 x2172 F (315)437-0432 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Global vars or Environment var on Class
Hi I cann't call Global vars or Environment var on Class.How to's i do to call it? I want to call variable same below. var $location =http://.$HTTP_SERVER_VARS['HTTP_HOST'].$_SERVER['REQUEST_URI'].?.$HTTP_SERVER_VARS['QUERY_STRING']; Thank you. Turbo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Global VARS.
Hello, To get ride of magic_quotes I do: function no_magicquotes() { global $HTTP_GET_VARS ; global $HTTP_POST_VARS ; global $HTTP_COOKIE_VARS ; if (get_magic_quotes_gpc()) { // Overrides GPC variables for (reset($HTTP_GET_VARS); list($k, $v) = each($HTTP_GET_VARS); ) $$k = stripslashes($v); for (reset($HTTP_POST_VARS); list($k, $v) = each($HTTP_POST_VARS); ) $$k = stripslashes($v); for (reset($HTTP_COOKIE_VARS); list($k, $v) = each($HTTP_COOKIE_VARS);) $$k = stripslashes($v); } } And it seems to work, But i have have a file like that: $VAR_mailadmin = [EMAIL PROTECTED] ; $VAR_urlgallery= http://www.siova.net/paris2; ; $VAR_categories[0][title] = Montréal by Night ; $VAR_categories[0][name] = Mtl by night ; $VAR_categories[0][file] = montreal_by_night ; ... And many others variables. And magic_quotes seems to work for global vars too. Is there a way to modify no_magicquotes() to make this function works with all global vars ? Another for...each...but how ? Thanks, Vincent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Global Vars = Off Windows/Linux Differeces???
Hi, I've made a website and because of presentationproblems I changed the oldstyle vars to the new globalvars mode (Hope its the right name for it, dont know if $_SESSION['user'] is a global or it is not???). Now the Website works perfect on my WAMP System with Apache 1.3.27 and PHP 4.3.0, but on my Linux Server the Login Functionality of the Website lets the User log in (Sessionmanagement is used at this point), but as i click on a link, the area where the username of the registered user should be shown, it shows just a number and doesnt let me log out. Instead it just shows a 0. Normaly it should be possible to do a login again from this point. On Windows everything works just fine. The Linux Machine is an Debain Woody / Apache 1.3.27 / php 4.2.3 Please help me, because my customers will jump on my neck if I dont, find out, where the problem is located. Hope you'll help me! Thanks very much Sascha
Re: [PHP] Global Vars = Off Windows/Linux Differeces???
Pretty hard to tell anything without any details about what you're doing... Sascha Braun wrote: Hi, I've made a website and because of presentationproblems I changed the oldstyle vars to the new globalvars mode (Hope its the right name for it, dont know if $_SESSION['user'] is a global or it is not???). Now the Website works perfect on my WAMP System with Apache 1.3.27 and PHP 4.3.0, but on my Linux Server the Login Functionality of the Website lets the User log in (Sessionmanagement is used at this point), but as i click on a link, the area where the username of the registered user should be shown, it shows just a number and doesnt let me log out. Instead it just shows a 0. Normaly it should be possible to do a login again from this point. On Windows everything works just fine. The Linux Machine is an Debain Woody / Apache 1.3.27 / php 4.2.3 Please help me, because my customers will jump on my neck if I dont, find out, where the problem is located. Hope you'll help me! Thanks very much Sascha -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Global Vars
Hi Everone, for my newest projekt i started to use global var like $_REQUEST['varname'] and so on. But in some cases i started again to use old var mode. Finally i have read some about there is need to define the vars, before I'm going to create the source for my webpages. But how can i make definitions like form action=test.php?action=update method=post working without usage of hidden fields. Or links like test.php?action=update and so on. Please gimme a hint Sascha
[PHP] Global vars
I have a question about global vars. Why is it that I have to declare a var global if I'm using it across included files. For example the only why I can get this var to work is by making it global. main.php ?php include loader.inc; include builder.inc; include render.inc; ? loader.inc ?php global $obj; $obj = new Whiz_bang(); ? builder.inc ?php global $obj; $obj-build_whizzer(); ? render.inc ?php render-html(); ? considering that if you took the could and just inserted the code form the included files into the main you would not need to make the var global why is that I need to when I cross files. I don't think I have read a good reasoning for this anywhere. My goal is simple to use as few global vars as possible which is why I ask. _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Global vars
global $var; does nothing outside of a function. You do not need to use global for this. $foo = 'bar'; include 'something_that_uses_foo.inc'; http://www.php.net/manual/en/language.variables.scope.php regards, Philip Olson On Sun, 2 Jun 2002, Anzak Wolf wrote: I have a question about global vars. Why is it that I have to declare a var global if I'm using it across included files. For example the only why I can get this var to work is by making it global. main.php ?php include loader.inc; include builder.inc; include render.inc; ? loader.inc ?php global $obj; $obj = new Whiz_bang(); ? builder.inc ?php global $obj; $obj-build_whizzer(); ? render.inc ?php render-html(); ? considering that if you took the could and just inserted the code form the included files into the main you would not need to make the var global why is that I need to when I cross files. I don't think I have read a good reasoning for this anywhere. My goal is simple to use as few global vars as possible which is why I ask. _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] global vars within 2-level functions
I have some code, in which I am using the function keyword to create subroutines of code (in otherwords, not true functions but rather reuseable chunks of other code). Yeah, it's ugly, but I need to do it this way for now. So my question is this: One of my subroutine/functions generates a variable. I would like to make this variable available to another subroutine/function, which is called from the first subroutine/function. If what I say is confusing, think of it like this: function1 - creates variable_A - calls function2 function2 - needs to access variable_A The problem is that this variable is not available to function2, even if I use the global keyword. The only way I can pass this variable to function2 is if I pass it as an argument. However, in some cases, I need to call function2 without this argument, but this creates some Warnings which I don't want to see. I don't want to just suppress these warnings, how can I either (a) Pass a variable from a function to a subfunction called from the first function (b) Pass a variable as an argument to a function but make that argument optional so that it does not have to exist to make the function legitimate. Thank you, Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global vars within 2-level functions
On Wednesday 03 April 2002 02:11, Erik Price wrote: (b) Pass a variable as an argument to a function but make that argument optional so that it does not have to exist to make the function legitimate. function function2 ($variable_A=) { } It's in manual under Functions -- original isn't it? :) -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Kids, the seven basic food groups are GUM, PUFF PASTRY, PIZZA, PESTICIDES, ANTIBIOTICS, NUTRA-SWEET and MILK DUDS!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global vars within 2-level functions
On Tuesday, April 2, 2002, at 01:24 PM, Jason Wong wrote: (b) Pass a variable as an argument to a function but make that argument optional so that it does not have to exist to make the function legitimate. function function2 ($variable_A=) { } Thanks for the pointer. I didn't realize that passing a blank argument would achieve this effect. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global vars within 2-level functions
On Tue, 2 Apr 2002, Erik Price wrote: On Tuesday, April 2, 2002, at 01:24 PM, Jason Wong wrote: (b) Pass a variable as an argument to a function but make that argument optional so that it does not have to exist to make the function legitimate. function function2 ($variable_A=) { } Thanks for the pointer. I didn't realize that passing a blank argument would achieve this effect. Here's another way to have optional arguments, just so you're at a wealth of solutions: function function2() { list ($variable_A) = func_get_args(); } miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] global vars in a function
Hi, Am I missing something? I'm trying to use vars set in my config.php file in a function, and can't seem to do it without using $GLOBALS[varname], which is a bit of a pain in the ---config.php--- $var1 = 1; --- ---something.php--- function foo { if($var1) { echo foo; // doesn't work } } function foo2 { if($GLOBALS[var1]) { echo foo; // does work } } --- Is there a way to make global vars available in each function, or is this just the way things go? Justin French - http://indent.com.au http://soundpimps.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php