camner
12-11-2005, 03:05 PM
I am taking an existing codebase (that I didn't write) and updating it for use with PHP 5.x...
The old code clearly took advantage of the fact that POST and GET data were automatically inserted into variables without use of the $_POST or $_GET arrays, which no longer works in PHP 5
The code also uses an html form that is submitted via javascriptdocument.frmproductlist.submit();
Now, here are my questions:
1. When a form is submitted this way, via javascript, the form fields are inserted into the $_REQUEST array, but not the $_POST array (nor the $_GET array). I have to admit I'm confused by this; why is this the case?
2. In order to get the form fields into the appropriate variables, I'm using extract($_REQUEST); Is there a better way?
3. In the old code, no provisions were made for escaping special characters such as ', " etc. as they were inserted into a database. So, I'm presuming that magic_quotes_gpc() must have been assumed to be on! This is poor programming practice, I know. I've read posts on this forum suggesting that addslashes()/stripslashes() is a poor way to code, and that mysql_real_escape_string() is preferable. It seems cumbersome to call that function for all strings to be inserted into the database...but even if that is done, how is the data "unescaped" when it is pulled out of the database?
Thanks for looking at this...
The old code clearly took advantage of the fact that POST and GET data were automatically inserted into variables without use of the $_POST or $_GET arrays, which no longer works in PHP 5
The code also uses an html form that is submitted via javascriptdocument.frmproductlist.submit();
Now, here are my questions:
1. When a form is submitted this way, via javascript, the form fields are inserted into the $_REQUEST array, but not the $_POST array (nor the $_GET array). I have to admit I'm confused by this; why is this the case?
2. In order to get the form fields into the appropriate variables, I'm using extract($_REQUEST); Is there a better way?
3. In the old code, no provisions were made for escaping special characters such as ', " etc. as they were inserted into a database. So, I'm presuming that magic_quotes_gpc() must have been assumed to be on! This is poor programming practice, I know. I've read posts on this forum suggesting that addslashes()/stripslashes() is a poor way to code, and that mysql_real_escape_string() is preferable. It seems cumbersome to call that function for all strings to be inserted into the database...but even if that is done, how is the data "unescaped" when it is pulled out of the database?
Thanks for looking at this...