Jump to content

Block certain data from being submitted


sphinx

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.

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.