Jump to content

security question:scrubbing user input


studentofstone

Recommended Posts

I am trying to keep the user input clean with this script but can't figure out what is wrong with it.

the error I am getting is Warning: preg_match() expects parameter 1 to be string,

$bad_strings = array(
                "content-type:",
                "mime-version:",
                "multipart/mixed",
			"Content-Transfer-Encoding:",
                "bcc:",
			"cc:",
			"to:",
  						);
if (preg_match($bad_strings, $first_name)) {
    die;

Link to comment
Share on other sites

preg_match takes (string, string) and you're passing in an array for the first parameter.  Not entirely sure what you're trying to do here...  If you want to check if $first_name exists in the array of bad words then use in_array.

I am trying to make sure the user input (which will be emailed after processing) is only being sent to the proper address by explicitly keeping out bcc: cc: etc. I already have a fair amount of validation, but I wanted to be sure people don't steal the data.

Is there a better way?

 

Warning: preg_match() expects parameter 1 to be string

 

$bad_strings = array(

/slaps forehead/

of course.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.