Jump to content

i have problem with my site i had to put $_GET['']; to every variable help me


kmk4

Recommended Posts

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 ok
but 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
Link to comment
Share on other sites

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 add

if ($_GET['ook'] == "one") {
echo "ok";
} else {
echo "not ok";
}

That should work.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

i downloaded the file .htaacess and i add
php_flag register_globals on
to the end of the file but i get server internal error
so what is the correct way to do it
this is the content of my .htacess file
[code]
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET

POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.net
AuthUserFile

/home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile

/home/mysite/public_html/_vti_pvt/service.grp
[/code]
Link to comment
Share on other sites

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).
Link to comment
Share on other sites

[quote author=kmk4 link=topic=117673.msg480273#msg480273 date=1165465134]
i downloaded the file .htaacess and i add
php_flag register_globals on
to the end of the file but i get server internal error
so what is the correct way to do it
this is the content of my .htacess file
[code]
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET

POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.net
AuthUserFile

/home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile

/home/mysite/public_html/_vti_pvt/service.grp
[/code]
[/quote]

kindly try :
[code]
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.net
AuthUserFile /home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp
php_flag register_globals on
[/code]

If you still get error, your server might not allow override controls.
Link to comment
Share on other sites

thank u very much
i 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 pages
then i tried extract($_REQUEST); it works very well with post and get and save my time so thank you very much
Link to comment
Share on other sites

[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 add
php_flag register_globals on
to the end of the file but i get server internal error
so what is the correct way to do it
this is the content of my .htacess file
[code]
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET

POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.net
AuthUserFile

/home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile

/home/mysite/public_html/_vti_pvt/service.grp
[/code]
[/quote]

kindly try :
[code]
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.net
AuthUserFile /home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp
php_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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.