Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/251910-block-certain-data-from-being-submitted/
Share on other sites

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
}

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.

 

 

 

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.

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.