Jump to content

PHP Mail Preview Page - Problem with browser compatibility


Revlet

Recommended Posts

I have been working on a script for the contact page at:

http://www.architecturalinstallationteam.com/sandbox/index.php?p=contact_us

 

 

I finally have managed to have a working script...in firefox. Internet Explorer 6, which unfortunately the majority of visitors to the AIT website will be using, has major problems with the Edit function.

 

 

First of all here is the code:

 

<?php session_start();

switch($_POST['view'])
{
case 1: /* first time submit, show preview */
   $type = "hidden";
   $vis_type = "none";
   $area_type = "absolute";
   $Name = $_POST['Name'];
   $Title = $_POST['Title'];
   $Company = $_POST['Company'];
   $Telephone = $_POST['Telephone'];
   $Email = $_POST['Email'];
   $Message = $_POST['Message'];
   $view = 2;
   
if($_SESSION["captcha"]==$_POST["captcha"])
{
    //CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
$EXTRA_INFO = "<div id='container'>
<strong>Are your sure you want to submit:</strong>
   <div id='left'>
   <p>Name:</p>
   <p>Title:</p>
   <p>Company:</p>
   <p>Telephone:</p>
   <p>Email:</p>
   <p>Message:</p>
   </div><!-- left -->
  <div id='right'>
   <p>$Name</p>
   <p>$Title</p>
   <p>$Company</p>
   <p>$Telephone</p>
   <p>$Email</p>
   <p>$Message</p>
  </div>
  <!-- right -->
  <div class='clear'></div>
</div><!-- container -->";
}
else {
echo "<strong><p style='color: #CC0000'>The code you entered was incorrect.</strong>";
}
   

   $FORM = "";

if($_SESSION["captcha"]==$_POST["captcha"])
{
    //CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
$INPUT_BUTTON = "<input type='image' src='images/Undo.png' name='submit' value='Edit'>  <input type='image' src='images/Mail.png' name='submit' value='Send'>";
}
else {
echo "  Please go back and try again.</p>";
$INPUT_BUTTON = "<div style='text-align: center;'><input type='image' src='images/Undo.png' name='submit' value='Edit'></div>";
}


   ;
   break;
case 2: /* second time submit, if edit pressed, then edit else submit */
   if($_POST['submit'] == "Edit")
     { /* Edit and reset to first time here */
       $Name = $_POST['Name'];
   $Title = $_POST['Title'];
   $Company = $_POST['Company'];
   $Telephone = $_POST['Telephone'];
   $Email = $_POST['Email'];
   $Message = $_POST['Message'];
       $type = "text";
   $vis_type = "block";
   $area_type = "";
       $view = 1;
       $INPUT_BUTTON = "<img src='captcha/captcha.php' alt='captcha image' /><br />
   					Please enter the three <strong><span style='color: #000000;'>black</span></strong> characters:  <input type='text' name='captcha' size='3' maxlength='3' /><br /><br />
   					<input type='image' src='images/Next.png' name='preview' value='Preview'>";
   //$FORM = "<form action='$PHP_SELF' method='post'>
   //		<input type='$type' name='0' size='4' value='Name:'>
   //		<input type='hidden' value='$view' name='view'>
   //		<input type='$type' name='Name' value='$Name'><br>";
       $EXTRA_INFO = "<strong>Edit Message:</strong><br>";
     }
   else
     { /* Submit info */
// Get POST variables
$EmailFrom = "AIT Website";
$EmailTo = "scott.bryant@aiteampro.com";
$Subject = "AIT Website - Contact Requested";
$Name = Trim(stripslashes($_POST['Name'])); 
$Title = Trim(stripslashes($_POST['Title'])); 
$Company = Trim(stripslashes($_POST['Company'])); 
$Telephone = Trim(stripslashes($_POST['Telephone'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// Create Email
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Title: ";
$Body .= $Title;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// Send Email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// Redirect 
if ($success){
  //print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php?p=sent\">";
include('include/sent.php');
$type = "hidden";
$vis_type = "none";
$area_type = "absolute";
}
else{
include('include/error.php');
$type = "hidden";
$vis_type = "none";
$area_type = "absolute";
  //print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php?p=error\">";
//$EXTRA_INFO = "Error! Message not successfully sent.<br><pre>$Name</pre>";
//$type = "hidden";
//$vis_type = "none";
}

}
   break;
default: /* either we've never been here or something has screwed our counter */
   $EXTRA_INFO = "<strong>Enter information below:</strong><br>";
   $INPUT_BUTTON = "<img src='captcha/captcha.php' alt='captcha image' /><br />
   					Please enter the three <strong><span style='color: #000000;'>black</span></strong> characters:  <input type='text' name='captcha' size='3' maxlength='3' /><br /><br />
				<input type='image' src='images/Next.png' name='preview' value='preview'>";
   $type = "text";
   $vis_type = "block";
   $area_type = "";
   $view = 1;
   break;
}
/* display our page accordingly */

echo $EXTRA_INFO;
echo "<form action=\"$PHP_SELF?p=contact_us\" method=\"post\" onsubmit=\"MM_validateForm('Name','','R','Title','','R','Company','','R','Email','','RisEmail');return document.MM_returnValue\">
<div id='container'>
<div id='left' style='display: $vis_type'>
   <p>Name:</p>
   <p>Title:</p>
   <p>Company:</p>
   <p>Telephone:</p>
   <p>Email:</p>
   <p>Message:</p>
</div><!-- left -->
  <div id='right' style='display: $vis_type'>
<input type='hidden' value='$view' name='view'>
<input type='$type' name='Name' value='$Name' size='50'><br>
    
    <input type='hidden' value='$view' name='view'>
    <input type='$type' name='Title' value='$Title' size='50'><br>
   
    <input type='hidden' value='$view' name='view'>
<input type='$type' name='Company' value='$Company' size='50'><br>
    
    <input type='hidden' value='$view' name='view'>
<input type='$type' name='Telephone' value='$Telephone' size='50'><br>
    
    <input type='hidden' value='$view' name='view'>
<input type='$type' name='Email' value='$Email' size='50'><br>
    	
<textarea name='view' style='position: absolute; visibility: hidden'>$view</textarea>
<textarea name='Message' cols='113' rows='8' style='position: $area_type; visibility: $type'>$Message</textarea><br>
  </div><!-- right -->
  <div class='clear'></div>
</div><!-- container -->";
echo "<div style='text-align: right;'>$INPUT_BUTTON</div>";
echo "</form>";

?> 

 

So I believe the problem is somewhere in the value='Edit' because it completely ignores the value and therefore goes straight to else --> php mailer --> then includes the mail sent page.

 

 

Note that the code above is included into the contact_us page which is dynamically included into the index with url parameter ?p=contact_us

 

 

Thanks for any help!

- Revlet

 

 

EDIT: Also the javascript form validation only works in Internet Explorer and not in Firefox but even without the onsubmit code the edit button has problems in IE

Link to comment
Share on other sites

For the 100th time, browsers send the x,y coordinates where an image button is clicked. The browsers that send the value="..." parameter are doing their own thing outside of the html specification - http://www.php.net/manual/en/faq.html.php#faq.html.form-image

 

 

Thanks for pointing me in the right direction, I didn't realize using an image submit button made a difference. Unfortunately I don't understand what I would have to change in my code to make it work.

 

I'm sorry if it's a pain but could I have a little more direction? I want to make this work and it's driving me crazy!

 

 

Thanks again,

Revlet

Link to comment
Share on other sites

That link contains an example of an image submit button with the name foo and an example of what that becomes as a variable in php POST/GET as foo_x and foo_y. Can you extrapolate that to what your code is doing?

 

If you have a button with name="submit", that will become $_POST['submit_x'] and $_POST['submit_y']. You only need to test for one or the other of those. Because the value is a pixel position, you can only really test for those being set using the isset() function, so, the name will need to indicate the desired function and the names will need to be unique for each different button.

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.