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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:27:21+00:00 2026-05-22T14:27:21+00:00

The PHP based validation of my form does not work in the latest versions

  • 0

The PHP based validation of my form does not work in the latest versions IE, Firefox or Opera. I click the submit button with empty values in my form fields to trigger validation but the page simply refreshes.

The odd thing is that validation and error messages work in Chrome and Safari.

View this for yourself here: http://www.directsponsor.org/contact/

Can anyone advise me on known issues regarding why PHP might fail on certain browsers certain browsers behave differently?

Apologies for the mountains of code in advance, though I presume its required:

Here’s the form:

    <form method="post" action="http://www.directsponsor.org/contact/">
  <fieldset>
  <ul>
  <?php if(isset($_POST['contactsubmit'])){
  if (!$contactnamevalidation){
  echo "<li class='contactfail'><p><img src='"; echo bloginfo('stylesheet_directory'); echo "/images/icons/101-large.png'>&nbsp;&nbsp;&nbsp;You did not input your <strong>name</strong>.</p></li>";
  }
  }
  ?>
  <li>
    <label for="contactname">Your name <em>(required)</em></label> 
    <input type="text" name="contactname" class="textbox" value="<?php if (isset($_POST['contactname'])) {echo htmlspecialchars($_POST['contactname'], ENT_QUOTES);    }?>">
 </li>
 <?php if(isset($_POST['contactsubmit'])){
  if (!$contactemailvalidation1){
  echo "<li class='contactfail'><p><img src='"; echo bloginfo('stylesheet_directory'); echo "/images/icons/101-large.png'>&nbsp;&nbsp;&nbsp;You did not input your <strong>email</strong>.</p></li>";
  }
  }
  ?>
 <?php if(isset($_POST['contactsubmit'])){
  if (!$contactemailvalidation2){
  echo "<li class='contactfail'><p><img src='"; echo bloginfo('stylesheet_directory'); echo "/images/icons/101-large.png'>&nbsp;&nbsp;&nbsp;You did not input a <strong>valid email</strong>.</p></li>";
  }
  }
  ?>
  <li>
    <label for="contactemail">Your email <em>(required)</em></label>
    <input type="text" name="contactemail" class="textbox" value="<?php if (isset($_POST['contactemail'])) {echo htmlspecialchars($_POST['contactemail'], ENT_QUOTES);    }?>">
 </li>
 <?php if(isset($_POST['contactsubmit'])){
  if (!$contactmessagevalidation){
  echo "<li class='contactfail'><p><img src='"; echo bloginfo('stylesheet_directory'); echo "/images/icons/101-large.png'>&nbsp;&nbsp;&nbsp;You did not input a <strong>message</strong>.</p></li>";
  }
  }
  ?>
  <li>
    <label for="contactmessage">Message <em>(required)</em></label>
    <textarea name="contactmessage"><?php if (isset($_POST['contactmessage'])) {echo htmlspecialchars($_POST['contactmessage'], ENT_QUOTES);    }?></textarea>
  </li>
  <li class="buttons">
  <label for="contactsubmit">&nbsp;</label><input type="image" src="/wp-content/themes/directsponsor/images/button-sendmessage.png" name="contactsubmit" value="Submit Message">

  <?php if(isset($_POST['contactsubmit'])){echo"<a href='http://www.directsponsor.org/contact/'><img src='/wp-content/themes/directsponsor/images/button-clearform.png'/></a>";} ?>
  </li>
  </ul>
  </fieldset>
  </form>

Here’s the (relevant part of the) validation:

    <?php 
if(isset($_POST['contactsubmit'])){

//Validation here.

}
?>

The answer

As suggested by Dr. Molle, IE, FireFox and Opera handle the value of images used as submit button differently in comparison to Chrome and Safari.

My validation began with:

if(isset($_POST['contactsubmit'])){

IE, Firefox and Opera posts the following values:

//Values for image as a submit button.
contactsubmit_x
contactsubmit_y

Since both of these value are different to contactsubmit, the if(isset()) condition isn’t triggered. To rememdy this I needed to use a form element other than the image as a submit button such as the email field:

if(isset($_POST['contactemail'])){

This will trigger the condition for validation whether or not contactemail is empty or not.

  • 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-22T14:27:22+00:00Added an answer on May 22, 2026 at 2:27 pm

    Look at this:

    if(isset($_POST['contactsubmit']))
    

    this variable does’nt exists in the failing browsers, if you use an image-submit there are variables $_POST['contactsubmit_x'] and $_POST['contactsubmit_y'] instead.

    It works in Chrome/Safari because they also send the variable “contactsubmit” if you set a value-attribute for the image-submit(but the occurence of this variable isn’t reliable as you see).

    But I would suggest not to use those variables at all. It depends on the browser if those variables will be send always or only if the button has been clicked, so you run into problems when a user uses [ENTER] to submit the form in some browsers.

    Check another variable, e.g. $_POST['contactemail'] , instead.

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

Sidebar

Related Questions

I have a PHP form that needs some very simple validation on submit. I'd
I have a complex input form within a PHP based web application. To structure
I have a contact form that is being submitted, I have PHP validation all
Login validation based on the username and password is done for the php application
I am creating a comment form based on the jquery validation plugin (http://docs.jquery.com/Plugins/Validation). I
I am creating a comment form based on the jquery validation plugin ( http://docs.jquery.com/Plugins/Validation
I would like to create a comment form based on the jquery validation plugin
On a PHP-based web site, I want to send users a download package after
I've got a PHP-based site where we allow users to upload a comma-separated text
Has anyone developed a PHP based Client for a WCF Service? I'm in the

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.