Jump to content

Can anyone tell me why this str_ireplace() isn't working?


horseatingweeds

Recommended Posts

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.