Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6205211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:13:55+00:00 2026-05-24T05:13:55+00:00

what i am attempting to build is an array from a database query in

  • 0

what i am attempting to build is an array from a database query in php mysql. loop through that array looking for a certain string with strpos.

when the register page loads, i include a file, this file source is below:

mysql_select_db($database_connBlog, $connBlog);
$query_rsBannedDomains = "SELECT * FROM banned_emailproviders";
$rsBannedDomains = mysql_query($query_rsBannedDomains, $connBlog) or die(mysql_error());
$row_rsBannedDomains = mysql_fetch_assoc($rsBannedDomains);
$totalRows_rsBannedDomains = mysql_num_rows($rsBannedDomains);


$bannedArray = array(); 
    do {
    array_push($bannedArray, $row_rsBannedDomains['domain_emailprovider']);
    }
    while ($row_rsBannedDomains = mysql_fetch_assoc($rsBannedDomains));

//print_r($bannedArray);

$emailaddress = $_POST['email_usr'];

foreach($bannedArray as $key => $domain){
    if(strpos($emailaddress, $domain) == false){
        echo (strpos($emailaddress, $domain));
    } else {
        header ("Location: http://www.disney.com");

    }
}

When the register page is submitted, it is submitted to itself. The include to the source above, is the second line in the register php file. the first line is the include for the database connection.

The odd thing is this works sometimes when I click back and re submit the form.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:13:56+00:00Added an answer on May 24, 2026 at 5:13 am

    You don’t need to load the whole table and then loop through it with PHP. In fact this is a very inefficient way of doing it. Just query the database to see if the domain part of the email address is one of the entries in the table instead.

    $emailaddress = substr ($_POST['email_usr'], strpos ($emailaddress = $_POST['email_usr'];
    , '@'));
    
    $query = "SELECT COUNT(*) AS banned FROM banned_emailproviders WHERE domain_emailprovider = '" . mysql_real_escape_string ($emailaddress) . "'"
    if (($res = mysql_query ($query)) && ($row = mysql_fetch_assoc ($res)) && ($row ['banned'] > 0))
    {
        // The domain was in the banned list
    }
    else
    if (!$res)
    {
        // Something went wrong querying the database
        die (mysql_error ());
    }
    else
    {
        // The domain wasn't in the banned list
    }
    

    Please note the above code hasn’t been tested so it might need some tweaking to work properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to build a simple method that creates an XML file from
I'm attempting to build Python 2.6.2 from source on my Linux system. It has
I'm attempting to build some C++ code that requires the Windows 7.0 SDK header
I'm attempting to build a custom control for Formtastic that takes a latitude and
I am attempting to build a script that will log data that changes every
I'm attempting to build a binary package that can be run on multiple Linux
I'm attempting to build a very simple wxPython GUI that monitors and displays external
i'm attempting to build a tiny (or perhaps not so tiny) formula that will
I'm attempting to build a page that displays the same set of information of
I am attempting to build a website that utilizes facebook auth based setting created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.