Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Array Help
#1
Hi,

I'm trying to use an array to pick out the "blacklisted" words from being used.

I'm currently trying to use this...

PHP Code:
$not_allowed = array("root","www","www2","ww3","admin","staff","dev","mail","web","cpanel","webmail","whm","host","ww2","members","member"); 

And to execute this, I'm using...

PHP Code:
if(in_array($not_allowed))
{
    
$_SESSION['error'] = $not_allowed_error;


What I want, is if anyone types any of those words in the specified text field, it will give them an error, but it's not picking them out for some reason.

Thanks.
Reply
#2
You need the $needle part of the in_array() function.

bool in_array ( mixed $needle , array $haystack [, bool $strict ] )

So you'll do something like this.

PHP Code:
$input $_POST['input'];
if(
in_array($input$not_allowed))
{
    
$_SESSION['error'] = $not_allowed_error;

Superman I am here to rescue you.
This is Support Forums not Support PMs.  Do not PM me for support unless it's private and site related.
Reply
#3
Wow!! Thank you so much! It works perfect. Smile

(rep+)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 941 07-27-2020, 11:26 PM
Last Post: tk-hassan
  What is array and the the use of it?can someone explain to me? Advertise4you 2 1,089 10-30-2011, 02:13 PM
Last Post: ★Cooldude★
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,668 10-10-2011, 01:00 PM
Last Post: Greyersting
  Put the data from a MySQL column in an array RPicard 3 1,089 06-01-2010, 01:51 PM
Last Post: RPicard
  $_POST array is empty RPicard 3 1,448 05-31-2010, 03:35 PM
Last Post: RPicard

Forum Jump:


Users browsing this thread: 1 Guest(s)