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> Link to comment https://forums.phpfreaks.com/topic/93979-can-anyone-tell-me-why-this-str_ireplace-isnt-working/ 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 />'; } Link to comment https://forums.phpfreaks.com/topic/93979-can-anyone-tell-me-why-this-str_ireplace-isnt-working/#findComment-481505 Share on other sites More sharing options...
horseatingweeds Posted March 2, 2008 Author Share Posted March 2, 2008 Thanks thorpe. Indeed. Link to comment https://forums.phpfreaks.com/topic/93979-can-anyone-tell-me-why-this-str_ireplace-isnt-working/#findComment-481784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.