Jump to content

Form does not work in IE


mallen

Recommended Posts

<?php 



ob_start();
//required for html headers error
//require_once('Connections/images.php'); 
include('includes/corefuncs.php');
// process the email
if (array_key_exists('send', $_POST)) {
  $to = 'me@you.com'; // 
  $subject = ' request';
  
  // list expected fields
  $expected = array('name','email','company','comments');
  // set required fields
  $required = array('name','email','comments');
  // create empty array for any missing fields
  $missing = array();
  
  // assume that there is nothing suspect
  $suspect = false;
  // create a pattern to locate suspect phrases
  $pattern = '/Content-Type:|Bcc:|Cc:/i';
  
  // function to check for suspect phrases
  function isSuspect($val, $pattern, &$suspect) {
    // if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
      foreach ($val as $item) {
    isSuspect($item, $pattern, $suspect);
    }
  }
    else {
      // if one of the suspect phrases is found, set Boolean to true
  if (preg_match($pattern, $val)) {
        $suspect = true;
    }
  }
    }
  
  // check the $_POST array and any sub-arrays for suspect content
  isSuspect($_POST, $pattern, $suspect);
  
  if ($suspect) {
    $mailSent = false;
unset($missing);
}
  else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
      // assign to temporary variable and strip whitespace if not an array
      $temp = is_array($value) ? $value : trim($value);
  // if empty and required, add to $missing array
  if (empty($temp) && in_array($key, $required)) {
    array_push($missing, $key);
    }
  // otherwise, assign to a variable of the same name as $key
  elseif (in_array($key, $expected)) {
    ${$key} = $temp;
    }
  }
}
  
  // validate the email address
  if (!empty($email)) {
    // regex to ensure no illegal characters in email address 
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
  array_push($missing, 'email');
  }
}
  
  // go ahead only if not suspect and all required fields OK
  if (!$suspect && empty($missing)) {
    // set default values for variables that might not exist



    // build the message
    $message = "Name: $name\n\n";
    $message .= "Company: $company\n\n";
    $message .= "Email: $email\n\n";
$message .= "Comments: $comments\n\n";


// limit line length to 70 characters
    $message = wordwrap($message, 70);
    
// create additional headers
$additionalHeaders = 'From: me';
if (!empty($email)) {
  $additionalHeaders .= "\r\nReply-To: $email";
  }

    // send it  
    $mailSent = mail($to, $subject, $message, $additionalHeaders);
if ($mailSent) {
  // $missing is no longer needed if the email is sent, so unset it
  unset($missing);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


</head>
<body id="contact">



<div id="wrapper">
<div id="topRight">
  
	<div id="error"><?php    
if (isset($missing)) {
    echo '<p>The following are required:</p>';
    echo '<ul>';
    foreach($missing as $item) {
      echo "<li>$item</li>";
    }
    echo '</ul>';
}
elseif ($_POST && $mailSent) {
echo '<p><strong>Your message has been sent. Thank you for your feedback.</strong></p>';
}

?>
</div>  
<form name="cssform" action="contact.php" method="post" >
      
   <ul>
     
      
           <li>
            <label for="name">Name: </label>
             <input name="name" type="text"  class="newfield" id="name"  size="35" <?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['name']).'"';} ?>/>
           </li>
            <li>
            <label for="email">Email: </label>
             <input name="email" type="text" class="newfield" id="email"  size="35"<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['email']).'"';} ?> />
           </li>
           <li>
            <label for="company">Company: </label>
            <input type="text"  name="company" class="newfield" id="company" size="35" <?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['company']).'"';} ?>/>
          </li>
          
   
   
   
       
         <li>
      
         <label for="comments">Comments: </label>
          <textarea name="comments" id="comments" cols="1" rows="4"<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['comments']).'"';} ?> ></textarea>
    
         </li>
   
   </ul>
    
    
     <input name="send" type="image" value="send" class="submitbutton" src="images/newbutton.jpg" />
    </form>

      </div>
     </div>

Link to comment
Share on other sites

http://us.php.net/manual/en/faq.html.php#faq.html.form-image

 

That's because to use an image as a submit button, you must following the HTML specification. The button is only required to send the x,y coordinates where the image was clicked. You might want to just use a hidden field with a name and a value that you can test to see if the form has been submitted.

Link to comment
Share on other sites

<input name="send" type="image" value="send" class="submitbutton" src="images/newbutton.jpg" />

 

and I changed it to:

 

<input name="send" type="submit" id="send" value="send" />

 

and it works in IE.

 

So just "type" is causing the issue.  So in this case Firefox is not following the HTML specification?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.