Posted by macca on 09/07/07 11:50
>$name = ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
>$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
>$subject = ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
>$msg = ltrim(rtrim(strip_tags($_POST['msg'])));
Not really an answer to your question, just a tip. You shouldnt repeat
code like this really,plus you dont need left trim and right trim
seperately, just call trim() which will do doth.
create a "sanitize" function:
function sanitize($dirty_data)(
$clean_data = trim(strip_tags(stripslashes($dirty_Data)));
return $clean_data;
}
Then:
$name = sanitize($_POST['name']);
$email = sanitize($_POST['email']);
$subject = sanitize($_POST['subject']);
$msg = sanitize($_POST['msg']);
Makes you code clearer and you can then re-use the function in any of
your applications then.
[Back to original message]
|