kmk4 Posted December 7, 2006 Share Posted December 7, 2006 i program a complete web site few years ago i change the host so my links didn't work at the new host i analyse the problem and i find that for example the code[code]<?if ($ook=='one'){echo ('ok');}else{echo ('not ok');}?>[/code]if i typed on the browser test.php?ook=one it still print not okbut if i added [code]$ook = $_GET['ook'];[/code]before the if it works so my quesions is :1-what is $_GET['']; and $_POST[''];... i think $_POST for forms and $_GET for access through test.php?var=constant if i was wrong correct me ?2-why the code work so fine without $_GET[] for years does it becouse the php verion change or upgrade in php version increase the security give details please?3-what is the easiest way to repair my site coz i don't want to read it all again and chick for every single variable on it and add $_GET[] to every page for every variable ?thanks for reading my topics Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/ Share on other sites More sharing options...
ki Posted December 7, 2006 Share Posted December 7, 2006 1. $_GET[] is for variables in the url, so yes you are correct.2. It could be because of that.3. I find it easier to just addif ($_GET['ook'] == "one") {echo "ok";} else {echo "not ok";}That should work. Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136640 Share on other sites More sharing options...
kmk4 Posted December 7, 2006 Author Share Posted December 7, 2006 thank you for fast replayingput about quesion no 3 that mean i'll search for every single if or every single variable and add $_GET[] is there any easiest way for example add code at the bigning of file or something Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136645 Share on other sites More sharing options...
ki Posted December 7, 2006 Share Posted December 7, 2006 you could try a function Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136652 Share on other sites More sharing options...
mansuang Posted December 7, 2006 Share Posted December 7, 2006 The easiest way to repair your site is use .htaccess to turn "register_globals" to be "on"To do that you will need to create .htaccess file in your site main directory (or the directory that contain yor php script)In you .htaccess should contain the following line.[code]php_flag register_globals on[/code]but remember, turning "register_globals" to "on" is easy but less secure coding. Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136658 Share on other sites More sharing options...
kmk4 Posted December 7, 2006 Author Share Posted December 7, 2006 i downloaded the file .htaacess and i addphp_flag register_globals onto the end of the file but i get server internal errorso what is the correct way to do itthis is the content of my .htacess file[code]# -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>AuthName www.mysite.netAuthUserFile /home/mysite/public_html/_vti_pvt/service.pwdAuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp[/code] Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136662 Share on other sites More sharing options...
btherl Posted December 7, 2006 Share Posted December 7, 2006 Here's another option..[code=php:0]extract($_GET);[/code]See http://sg.php.net/manual/en/function.extract.php for details. It will import all your GET variables. Be aware that evil users may set extra variables you didn't expect, so be careful.Also, note that if some of your forms use post instead of get, this won't get those too. You might want to do[code=php:0]extract($_REQUEST);[/code]That will get you both get and post variables (and cookies too I think). Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136664 Share on other sites More sharing options...
mansuang Posted December 7, 2006 Share Posted December 7, 2006 [quote author=kmk4 link=topic=117673.msg480273#msg480273 date=1165465134]i downloaded the file .htaacess and i addphp_flag register_globals onto the end of the file but i get server internal errorso what is the correct way to do itthis is the content of my .htacess file[code]# -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>AuthName www.mysite.netAuthUserFile /home/mysite/public_html/_vti_pvt/service.pwdAuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp[/code][/quote]kindly try :[code]# -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>AuthName www.mysite.netAuthUserFile /home/mysite/public_html/_vti_pvt/service.pwdAuthGroupFile /home/mysite/public_html/_vti_pvt/service.grpphp_flag register_globals on[/code]If you still get error, your server might not allow override controls. Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136674 Share on other sites More sharing options...
kmk4 Posted December 7, 2006 Author Share Posted December 7, 2006 thank u very muchi started to reread my code and started to add $_GET and search for every single variable and see it will be getted or posted and start to modify some pagesthen i tried extract($_REQUEST); it works very well with post and get and save my time so thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136682 Share on other sites More sharing options...
kmk4 Posted December 7, 2006 Author Share Posted December 7, 2006 [quote author=mansuang link=topic=117673.msg480285#msg480285 date=1165466293][quote author=kmk4 link=topic=117673.msg480273#msg480273 date=1165465134]i downloaded the file .htaacess and i addphp_flag register_globals onto the end of the file but i get server internal errorso what is the correct way to do itthis is the content of my .htacess file[code]# -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>AuthName www.mysite.netAuthUserFile /home/mysite/public_html/_vti_pvt/service.pwdAuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp[/code][/quote]kindly try :[code]# -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>AuthName www.mysite.netAuthUserFile /home/mysite/public_html/_vti_pvt/service.pwdAuthGroupFile /home/mysite/public_html/_vti_pvt/service.grpphp_flag register_globals on[/code]If you still get error, your server might not allow override controls.[/quote]thank you very much 2 and i tried it and i found that my server do not allow override controls. Quote Link to comment https://forums.phpfreaks.com/topic/29759-i-have-problem-with-my-site-i-had-to-put-_get-to-every-variable-help-me/#findComment-136683 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.