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

  • SEARCH
  • Home
  • 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 9204637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:45:27+00:00 2026-06-17T23:45:27+00:00

I have a form with multiple ’email’ input fields. each is checked in mysql

  • 0

I have a form with multiple ’email’ input fields. each is checked in mysql to check if its in the database. what I have now works if an incorrect email is in one of the fields it echo’s the right message and if all fields are empty it also echo’s the right message. And if the last input field is a correct email it also works. the one problem is that if a correct email address is in one or more of the fields that is not the last one, and there are no other incorrect emails, it will echo “none filled in”. I can rectify this by adding a break inside {$x = "1"} but then that messes up the mysql check as it needs to continue until/if the condition is not met. is there anything I can do?

foreach($_POST as $value)
  {
     if(empty($value))
      {
       $x = "0";
      } else
     if(!empty($value))
      {
        $usercheck =  "SELECT email FROM users WHERE email = '$value'";
        $usercheck = $db->query($usercheck);

     if($usercheck->num_rows > 0)
      {
        $x="1";
      } else
        {
          $x="2"; break;
        }
      }
  } 

if($x == "0") {echo "none filled in";}
if($x == "1") {echo "all good";}
if($x == "2") {echo $value." is not a user";} 
  • 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-06-17T23:45:28+00:00Added an answer on June 17, 2026 at 11:45 pm
    $i=1;  
    foreach($_POST as $value)
          {
             if(empty($value))
              {
               $x = "0";
              } else
             if(!empty($value))
              {
                $usercheck =  "SELECT email FROM users WHERE email = '$value'";
                $usercheck = $db->query($usercheck);
    
             if($usercheck->num_rows > 0)
              {
                $x="1";
              } else
                {
                  $x="2";
                }  
              }
           $field[$i]=$x;
           $i++;
          } 
    

    Now you have all three field results in $field array in 1st, 2nd and 3rd position.

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

Sidebar

Related Questions

I have a form that asks users to input numbers into multiple form fields.
I have a form with multiple tabs. Each tab has its own <form> ,
I have a form with multiple text input fields and sub-forms. Is there a
I have a form with multiple input fields, but only want to use one
I have a form with multiple fields, and each time the user changes a
I have a form with multiple input fields. I'm using a blur function to
I have a form with multiple input fields that use datepicker. I have just
I have a html form with multiple input fields, a name and an address
I have form with multiple input type=radio with text next to them. I want
I have a form with multiple textboxes which are created dynamically, now all these

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.