|
-
Mar 1st, 2006, 11:48 AM
#1
Thread Starter
Addicted Member
Post only
How to enforce that visitor is not using query string to access the page instead using post method only.
I don't want visitor should go thru GET method.
-
Mar 1st, 2006, 02:44 PM
#2
Re: Post only
All variables from the query string are loaded into the $_GET array and all variables from the HTTP body in a POST request are loaded into $_POST. If you want to ensure that your users are using a post request, use the $_POST array.
PHP Code:
$var = $_POST['form_var_name'];
-
Mar 9th, 2006, 11:38 AM
#3
Junior Member
Re: Post only
This is a bit of code i wrote so if the users uses a GET request then it writes their IP to a text file!
PHP Code:
<?php
$ipbanfile = "/home/site/public_html/Ipban.ban"; #IP Ban File
if($_SERVER['REQUEST_METHOD'] == "GET"){
$fp = fopen($ipbanfile, "a+");
fwrite ($fp, "{$_SERVER['REMOTE_ADDR']}");
fclose($fp);
die("So close... yet so far.");
}
?>
Last edited by Winsocket; Mar 9th, 2006 at 07:33 PM.
-
Mar 9th, 2006, 05:21 PM
#4
Hyperactive Member
Re: Post only
i see an error already...
PHP Code:
fwrite ($fp, "$_SERVER['REMOTE_ADDR']");
should be
fwrite ($fp, "$_SERVER[REMOTE_ADDR]");
or
fwrite ($fp, $_SERVER['REMOTE_ADDR']);
Without balance, there could only be chaos.
Without chaos, there could be no balance.
I live with karma. Eat with destiny. Dream of life without shackles....
Yet. If life had no consequences, life could not exist, nor could it flourish.
If at first you dont succeed.You're screwed.
C++/Java NOOB.
I aint a professional at PHP, but if i can help i will.
-
Mar 9th, 2006, 06:20 PM
#5
Re: Post only
Code:
fwrite ($fp, "$_SERVER[REMOTE_ADDR]");
You shouldn't use that either, you have not included REMOTE_ADDR in quotes. This would be correct:
"{$_SERVER['REMOTE_ADDR']}"
-
Mar 9th, 2006, 07:07 PM
#6
Junior Member
Re: Post only
Yeah, edited it, sorry i wrote that from memory. Simple mistake I also didn't need the extra die(); and exit(); so edited that as well. so...
PHP Code:
<?php
$ipbanfile = "/home/site/public_html/Ipban.ban"; #IP Ban File
if($_SERVER['REQUEST_METHOD'] == "GET"){
$fp = fopen($ipbanfile, "a+");
fwrite ($fp, "{$_SERVER['REMOTE_ADDR']}");
fclose($fp);
die("Please do not use the GET method!");
}
?>
Last edited by Winsocket; Mar 9th, 2006 at 07:35 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|