Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Remove Slashes on Submitted Input Values
How To Remove Slashes on Submitted Input Values? - PHP Script Tips - Processing Web Forms
✍: FYIcenter.com
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! :->"
2007-04-22, 5377👍, 0💬
Popular Posts:
What is triple constraint triangle in project management ? Project Management triangle is depicted a...
How can I search for data in a linked list? Unfortunately, the only way to search a linked list is w...
Can you explain steps in function points? Below are the steps in function points: >First Count ILF, ...
What is CMM and different levels? explain? The Capability Maturity Model (CMM) is a process capabili...
How To Use mysqlbinlog to View Binary Logs? - MySQL FAQs - Server Daemon mysqld Administration If yo...