Forum Moderators: coopster

Message Too Old, No Replies

Can a script accept both post and get?

         

codebreaker

6:22 am on Jul 28, 2005 (gmt 0)

10+ Year Member



I am relatively new to PHP. I'm writing a relatively simple script with a small form on it. It posts to itself, then saves and displays the data. Works great.

Basically the code stores weblinks, and when called it retrieves each page, compares the MD5 hashes with those stored, and displays whether the pages have changed or not.

I wanted to add a feature where I could pass a variable within the weblink to specify a particular page to check, so that I could run the script as a cron job, and it would return the answer from the data. I used:


if ((!isset($_POST['action'])) and (!isset($_GET['check']))) {
#perform check on data, print response
} elseif ($_POST['action'] == "submit") {
#save data
} elseif (isset($_GET['check'])) {
#perform check on data, print response
}

When I run the script using the variable 'check' in the link, it runs through the data check code, I see the response on the screen, but it says 'page loading' for a long time. In the mean time, the error_log file grows to hundreds of megs in size. I cut and pasted the EXACT code from the POST['action'] into GET['action'], but this problem persists.

I haven't debugged a whole lot, because each run takes a while to finish generating the huge error_log file, and because I'm afraid I'm taxing the server too much. I can post the code that is running, but like I said, it runs perfectly when POSTed. What am I missing?

Anyango

10:16 am on Jul 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey

Couldnt understand your post very well, perhaps i am feeling sleepy.

but if you are looking for someting like getting a request variable either its a POST or a GET then u can simply use this

$var1=$_REQUEST['var1'];

it can handle both

$var1=$_POST['var1'];
$var1=$_GET['var1'];

Kami

jatar_k

3:29 pm on Jul 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can use $_REQUEST but it is not a very secure way of doing things

there is a problem in your logic somewhere, maybe try a little error checking and see if can isolate the specific problem a little more

you can post some code as well, just not too much ;)

Mr_Fern

11:51 pm on Jul 28, 2005 (gmt 0)

10+ Year Member



Well to at least prevent the error_log from generating while you're debugging, add this line of code:
error_reporting(0);

Also, if it works when you're method is POST, you might want to check the code for the last elseif. Perhaps you can paste it here and someone can see the problem.