Jump to content

Searching for something within a string


MainStWebGuy

Recommended Posts

Hello all, Newbie here:

 

I'm practicing validating contact forms i've been using on clients websites and trying to come up with a solid way to prevent them.

 

Focusing on header injections in email fields i started thinking: Is there a way to search within a string to look for malicious code? I've read about email injection a little bit and see that some people will use "CC:[email protected], [email protected], email3... "

 

Assuming i was using a form like this:

<form action="mail.php" method="POST">
name: <input type="text" name="name" />
email: <input type="text" name="email" />
</form>

 

and my mail.php had something like this:

<?php
    $email = htmlspecialchars($_POST['email']);
?>

 

is there a way that i could search within the $email variable to see if it contained characters like "CC:" ?

 

if i'm heading in the wrong direction and some of you have some other ways you've found that work well with keeping out the spam i'd sure appreciate a point in the right direction  :)

 

have any of you found some nice tutorials out there that deal with this? I've googled it, but alas, the results are many, and many of them seem to be very easily worked around (from a spammers point of view)

 

thanks in advance!

Jason

Link to comment
https://forums.phpfreaks.com/topic/149866-searching-for-something-within-a-string/
Share on other sites

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.