horseatingweeds Posted March 2, 2008 Share Posted March 2, 2008 I'm trying to experiment so I can write a sanitizer for some email form inputs. But I can't figure out what I'm doing wrong here. Anyone who actually knows what they're doing see my problem? <?php $name = $_POST['name']; $email = $_POST['email']; function spamWash($string) { $badstrings = array( "to:", "cc:", "bcc:", "%20","%0a","%0d", "content-type:","mime-version:","multipart/mixed","boundary=", "content-transfer-encoding","content-disposition:"); str_ireplace($badstrings,'2',$string); return $string; } $fields = array($name, $email); foreach ($fields as $field) { spamWash($field); echo $field. '<br />'; } ?> <form name='form1' id='form1' enctype='multipart/form-data'action = "test-mail.php" method = "post" > Name <input type="text" name="name" size="30" maxlength='100' value='' /><br /> Email <input type="text" name="email" size="30" maxlength='100' value='' /><br /> <input type="submit" id='submit' name='submit' value=" Send "> </form> Quote Link to comment Share on other sites More sharing options...
trq Posted March 2, 2008 Share Posted March 2, 2008 You never capture what your function returns... foreach ($fields as $field) { $field = spamWash($field); echo $field. '<br />'; } Quote Link to comment Share on other sites More sharing options...
horseatingweeds Posted March 2, 2008 Author Share Posted March 2, 2008 Thanks thorpe. Indeed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.