RE: [PHP] addSlashes Question

From: Date: Wed, 01 Aug 2007 20:27:26 +0000
Subject: RE: [PHP] addSlashes Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-260024@lists.php.net to get a copy of this message
[snip] $first = "'".addslashes($_POST['firstname'])."'"; $last = "'".addslashes($_POST['lastname'])."'"; $email = "'".addslashes($_POST['email'])."'"; $address = "'".addslashes($_POST['address'])."'"; $city = "'".addslashes($_POST['city'])."'"; $state = "'".addslashes($_POST['state'])."'"; $zip = "'".addslashes($_POST['zip'])."'"; $comments = "'".addslashes($_POST['comments'])."'"; $newsletter = "'".addslashes($_POST['signup'])."'"; $contact = "'".addslashes($_POST['contact'])."'"; I can understand addSlashes for the first and last name, but question the need in the other variables, please inform. [/snip] There is safety in numbers! While a lot of these fields may not ever contain anything that would need to be escaped the name fields and comments field would definitely need this. Also, if this is filled out by 'external' users you do not want them to be able to enter anything (like a SQL injection attack in the comments field) that might cause a problem of some sort. Another option would be htmlentities()

« previous php.general (#260024) next »