Validating my PHP-based form does not work in recent versions of IE, Firefox, or Opera. I click the submit button with empty values in my form fields to initiate validation, but the page just refreshes.
The odd thing is that check messages and errors work in Chrome and Safari.
Take a look here: http://www.directsponsor.org/contact/
Can someone advise me on known issues regarding why PHP might not work in certain browsers, some browsers behave differently?
Sorry for the mountains of code in advance, although I assume this is necessary:
Here is 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'> 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'> 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'> 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'> 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"> </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 (important part) of the check:
<?php
if(isset($_POST['contactsubmit'])){
// Check here.
}
?>
Answer
, IE, FireFox Opera , -, Chrome Safari.
:
if(isset($_POST['contactsubmit'])){
IE, Firefox Opera :
//Values for image as a submit button.
contactsubmit_x
contactsubmit_y
contactsubmit, if(isset()) . , , , , :
if(isset($_POST['contactemail'])){
, contactemail.