sphinx Posted November 27, 2011 Share Posted November 27, 2011 Hello, Basically, What I'm looking for would be for a method of blocking certain email addresses from being submitted in a form, I need it to block certain emails that are on the list. I think the best way to describe it would be a form submission blacklist that is checked before it gets submitted. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/251910-block-certain-data-from-being-submitted/ Share on other sites More sharing options...
Pikachu2000 Posted November 27, 2011 Share Posted November 27, 2011 Store the blacklisted addresses in an array in a config file, or even in a database table. Array method: $blacklisted = array( lower-case blocked addresses here ); $address = 'BaDaDdReSs@pr0n_site.xxx'; if( in_array( strtolower($address), $blacklist ) { // block } else { / allow } Quote Link to comment https://forums.phpfreaks.com/topic/251910-block-certain-data-from-being-submitted/#findComment-1291663 Share on other sites More sharing options...
sphinx Posted November 27, 2011 Author Share Posted November 27, 2011 Cheers Pik, I can see where you're coming from, but can you explain: $blacklisted = array( lower-case blocked addresses here ); That, because I thought that '$address = 'BaDaDdReSs@pr0n_site.xxx';' was the area in which you inputted blocked addresses. I simply could include this in the process.php area aka: <?php if (isset($_REQUEST['email'])) { $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $from = $_REQUEST['from'] ; $amount = $_REQUEST['amount'] ; $message = $_REQUEST['message'] ; $from2 = '[email protected]'; $from = $from; mail("[email protected] ", "$subject", $message, "From:" . $from); } $headers = "From:" . $from; header('Location: success.php'); ?> I literally, just want an area where I can include multiple blocked address in the 'email' field. Thanks alot. Quote Link to comment https://forums.phpfreaks.com/topic/251910-block-certain-data-from-being-submitted/#findComment-1291664 Share on other sites More sharing options...
Pikachu2000 Posted November 27, 2011 Share Posted November 27, 2011 in_array() performs a case-sensitive check to see if the value of the first parameter exists in the array specified as the second parameter. If it does, it returns TRUE, else FALSE. So, you create an array of lower case email addresses to use as the blacklist in $blacklisted, then check the strtolower()ed value of $address against it. If it's in the array it's blacklisted, otherwise it's fine. Quote Link to comment https://forums.phpfreaks.com/topic/251910-block-certain-data-from-being-submitted/#findComment-1291666 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.