By default, when input values are submitted to the PHP engine, it will add slashes to protect single quotes and double quotes. You should remove those slashes to get the original values by applying the stripslashes() function. Note that PHP engine will add slashes if the magic_quotes_gpc switch is turned off. The PHP script below is an enhanced version of processing_forms.php with slashes removed when magic_quotes_gpc is turned on:<?php print("<html><pre>"); $count = count($_REQUEST); print("Number of values: $count\n"); foreach ($_REQUEST as $key=>$value) { if (is_array($value)) { print(" $key is an array\n"); for ($i = 0; $i < count($value); $i++) { $sub_value = $value[$i]; if (get_magic_quotes_gpc()) { $sub_value = stripslashes($sub_value); } print(" ".$key."[".$i."] = ".$sub_value."\n"); } } else { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } print(" $key = $value\n"); } } print("</pre></html>\n");?>Now if you submit the same data again as in the previous exercise, you will get the original values as:Number of values: 2 name = Alan comment = I want to say: "It's a good site! :->"
PHP
Topic: PHP Forms
How To Remove Slashes on Submitted Input Values?
Browse random answers:
What are the method available in form submitting?
What are the differences between GET and POST methods in form submitting?
How To Create a Web Form?
How To Generate a Form?
what are the various methods to pass data from one web page to another web page ?
Where Is the Submitted Form Data Stored?
How To Retrieve the Submitted Form Data?
What Happens If an Expected Input Field Was Not Submitted?
How To Avoid the Undefined Index Error?
How To List All Values of Submitted Fields?
What Are Input Values of SELECT Tags?
How To Specify Input Values for Radio Buttons?
How To Specify Input Values for Checkboxes?
How To Supply Default Values for Text Fields?
How To Remove Slashes on Submitted Input Values?
How To Support Hidden Form Fields?
Difference between Get and Post?
Difference between $_GET and $_POST ?
What is $_REQUEST method for ?
How can we access the data sent through the URL with the GET method?
How can we access the data sent through the URL with the POST method?
what is max POST size.
Default upload max file size of file a file in php.ini?.