I have an admin page (consists of a textarea) and save my posts into the database by using ajax and PHP. Sometimes ajax returns 403, sometimes not. PHP works perfectly but AJAX.
AJAX
serdata = 'text='+$("#ptext").val();
$.ajax({
type:"POST",
url:"../check/postcheck.php",
data:serdata,
cache:false,
success:function(result){
some html works
},
error:function(error){
some html works
}
});
I noticed that, when I write some special characters or some words that have meaning in SQL, get 403. So, I decided to create a method. For example, instead "SELECT", I write quoquoSELECTquoquo. So AJAX sends the word quoquoSELECTquoquo to PHP without error. PHP changes quoquoSELECTquoquo to "SELECT" and can save it into database perfectly. But, there are a lot of words or characters. So I have to do a lot of changes between ajax and php.
- So, as I know, this problem is related to mod_security. Server's firewall doesn't accept some words and characters. But I don't want to disable mod_security because of SQL Injection. Am I disable mod_security for just a couple of files.
- If not, is there any easy method to achieve this. I created at least 30 changes, but still get errors for some new words or simple characters. So I fed up to change words and characters again and again.
Some examples of errors and success,
AJAX sends quoquoselectquoquo , PHP changes it to "select" , no error.
AJAX sends quoquoselect" , PHP changes it to "select" , no error.
AJAX sends "select" , error 403.
AJAX sends (select) , sometimes error 403, sometimes no error
AJAX sends prnthsselect) , PHP changes it to (select) , no error.
AJAX sends & , error 403.
AJAX sends ndsymbl , PHP changes it to & , no error.
and the list goes on...