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 7677485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:25:59+00:00 2026-05-31T17:25:59+00:00

Ahoy all. I’ve got a contact form PHP script. I use it for multiple

  • 0

Ahoy all. I’ve got a contact form PHP script. I use it for multiple sites since it’s quick and easy. Basically, it loops through ALL the form fields in a contact form, no matter what they are. Makes it so I don’t have to manually do the POST thing one by one.

ANYWAY, my question is simple. Below is a snippet of the code:

if ($thisField != "contact-submit") {
    if (($thisField != "human2"))  {
         $msg .= "<b>".$thisField ."</b>: ". $thisValue ."<br>";
    }
    }

Now, the problem with it doing this loop is it picks up ALL things submitted, including the SUBMIT BUTTON and my hidden form field to deter robots. I don’t want to display THOSE fields to my clients.

So instead of doing these two nested loops, I was thinking of doing a

if (($thisField != "human2") or ($thisField != "contact-submit")

but it just doesn’t work… I have also tried the || operator as well.

What am I missing?

  • 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-31T17:26:01+00:00Added an answer on May 31, 2026 at 5:26 pm

    That expression always evaluated to true. If you compare a value to two different values, it is always unequal to at least one of them.
    I think you meant to use and, or &&, so you can check if the value isn’t any of those two values.

    if (($thisField != "human2") && ($thisField != "contact-submit")
    

    or

    if (!($thisField === "human2" or $thisField === "contact-submit"))
    

    or

    if (($thisField === "human2" or $thisField === "contact-submit") === false)
    // Because you might easily overlook the exclamation mark in the second example
    

    or use in_array

    if (! in_array($thisField, array('human2', 'contact-submit')))
    // Easier add extra fields. You could stick the array in a variable too, for better readability
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ahoy all! Long story short with this one if you don't mind lending a
Ahoy hoy everyone :) Here is a list of links. You will need it
Ahoy, I'd like to mount a virtual drive myself on Windows XP, I guess
Ahoy! I'm trying to create a reusable UIView (for various reasons) similar to the
Ahoy! I've been looking into updating some old test code in an attempt to
Ahoy, I'm working on an OpenGL ES based game for Android using the NDK.
We've got a system (MS SQL 2008 R2-based) that has a number of input
I have an LPTSTR for a file path, i.e. C:\Program Files\Ahoy . I would
Ahoy! I was wondering if there's a way to configure eclipse not to open
Ahoy Stack Overflow! This be mai first post... I'm attempting to identify users with

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.