Forum Moderators: coopster

Message Too Old, No Replies

PHP restrict POST except on when condition met?

         

JAB Creations

1:18 am on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to restrict POST commands to Apache except when certain condition(s) are met. I already have my condition I just do not know how to go about it.

Something like....

if!(condition (does not meet spec))!
{
?disable post?
}

I know what I'm going to put between! but not between?.

John

jatar_k

6:05 pm on Jan 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can't really disable POST though if you have a form and your criteria isn't met you could hide the actual submit button

islandlizard

4:29 am on Jan 4, 2006 (gmt 0)

10+ Year Member



You have two options here, use Javascript to validate the form before its submitted, or allow submission and validate the contents of the post variable.

Option two qwould look something like:

if (empty($_POST['required_field']){
//Spit out the error and redisplay the form with errors highlighted
} else{
//process the form and display a confirmation
}

NOTE: If you use Javascript to validate the form prior to submission, you must *STILL* validate the form after submission to check for those folks with Javascript disabled.

Have fun.