Jump to content

Recommended Posts

Hello!

 

I have a script on a website that is supposed to email users messages/alerts, and it was working fine on PHP 5.2, but doesn't work on PHP 5.4. It doesn't include any of the $variables in the email it sends. Any ideas? The webpage shows correctly, says it was sent, and sends a mostly blank email. (This is not all the code, but the important workings of it.) Is there something I need to reference differently for 5.4?

 

Any solutions would be greatly appreciated!

 

<?php
if (isset($acode) && $acode != 'unset') {
echo"<div style=\"font-size: 110%\">Send an Alert for:<br /><b>
  $location  >  $dept  >  $alert</b>
<br /><br />
</div>
<form name=\"alert\" onsubmit=\"return isReady(this)\" action=\"$formaction\" method=\"POST\">
<input type=\"hidden\" name=\"Location\" value=\"$location\">
<input type=\"hidden\" name=\"Department\" value=\"$dept\">
<input type=\"hidden\" name=\"Code\" value=\"$acode\">
<input type=\"hidden\" name=\"Alert\" value=\"$alert\">
<input type=\"hidden\" name=\"Contacts\" value=\"$tocode\">
Your name:
<br />
<input type=\"text\" name=\"Name\" size=\"40\" maxlength=\"70\" value=\" Required\" onfocus=\"if(this.value==' Required')this.value='';\" onblur=\"if(this.value=='')this.value=' Required';\"><br />
<br />
Your e-mail address:
<br />
<input type=\"text\" name=\"Email\" size=\"40\" maxlength=\"90\" value=\" Required\" onfocus=\"if(this.value==' Required')this.value='';\" onblur=\"if(this.value=='')this.value=' Required';\"><br />
<br />
Brief message:   <span style=\"color: #666666; font-size: 70%\">
Please keep in point form if possible. </span>
<br />
<textarea name=\"Message\" cols=\"65\" rows=\"7\" maxlength=\"5000\">
</textarea>
<span class=\"smbr\">
<br />
<br />
</span>
<br />
<div style=\"color: #666666; font-size: 70%; text-indent: 50px\">
All fields required. Include date & time of occurance if applicable.
</div><br />
<input type=\"hidden\" name=\"Date\" value=\"$date\">
<input type=\"hidden\" name=\"action\" value=\"submitted\">

<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td align=\"center\" width=\"25%\">
<input type=\"submit\" name=\"SUBMIT\" id=\"mySender\" value=\"Send...\" onclick=\"return monitor()\" style=\"margin: 0px 0px 0px 10px\">
</td>
<td align=\"left\" width=\"75%\" style=\"color: #666666; font-size: 70%\">
Please wait a moment after pressing send. If you do not get a confirmation message<br /> after 10 seconds, please press F5 to refresh the page and try again.
</td>
</tr>
<tr>
<td align=\"left\" colspan=\"2\" style=\"color: #666666; font-size: 70%\">
<br /><br />
<b>Your alert will be sent to the following people:</b><br />
$who
</td>
</tr>
</table>
</form><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
 }

 else {
 print "
 <form>
 <div style=\"color: #999999; font-size: 120%\" align=\"center\">
Please select a location and the type of alert.
 </div>
 </form>
 ";
 }
 ?>
<?php
 if (isset($_POST['action']) && $_POST['action'] == 'submitted')
 {
// find multiple correct recipients based on the proper code
$tocode = $HTTP_POST_VARS["Contacts"];
// convert variables from reference file, find values - email address string separated by commas
$tocontacts = $$tocode;
$to = $tocontacts;
$alert = $HTTP_POST_VARS["Alert"];
$email = $HTTP_POST_VARS["Email"];
$name = $HTTP_POST_VARS["Name"];
$location = $HTTP_POST_VARS["Location"];
$department = $HTTP_POST_VARS["Department"];
$subject = "ALERT - $alert";
$details1 = $HTTP_POST_VARS["Message"];
$details2 = str_replace("\n", "<br />", $details1);
$details3 = stripslashes($details2);
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $email\r\n";
// account for alerts archive
$headers .= 'Cc: ealerts@email.com' . "\r\n";
// BCC of all alerts
// $headers .= 'Bcc: bcc@email.com' . "\r\n";
$messagetop = '<html><head><title>Alert</title></head><body style="font-family: Arial, sans-serif"><br><font size="+2" color="#006600"><b>ALERT</b></font><br /><table style="font-family: Arial, sans-serif">';
$messagemid .= '<tr><td colspan="2"><hr style="color: #004400" /></td></tr><tr><td colspan="2"><b>';
$messagemid .= $location;
$messagemid .= '   >   ';
$messagemid .= $department;
$messagemid .= '   >   ';
$messagemid .= $alert;
$messagemid .= '</b></td></tr>';
$messagemid .= '<tr><td colspan="2"><hr style="color: #004400" /></td></tr><tr><td><b>Message:</b></td><td>';
$messagemid .= $details3;
$messagemid .= '<br /></td></tr>';
$messagemid .= '<tr><td colspan="2"><hr style="color: #004400" /></td></tr><tr><td><b>Name:</b></td><td>';
$messagemid .= $name;
$messagemid .= '<br /></td></tr>';
$messagemid .= '<tr><td colspan="2"><hr style="color: #004400" /></td></tr><tr><td><b>Email:</b></td><td>';
$messagemid .= $email;
$messagemid .= '<br /></td></tr>';
$messageend = '</table><br /><br /><br /><font size="-1" color="#004400"><b>Sample</b></font><br /></body></html>';
$message = $messagetop . $messagemid . $messageend;
//--------------- Assemble Auto Response -----------
$resmessagethanks = '<tr><td colspan="2">Thank you for sending an Alert!<br /><br />The following is for your reference:<br /><br /></td></tr>';
$resmessageend = '</table><br /><br /><br /><font size="-1" color="#004400"><b>Please note: Replying to this automated message will not reach anyone else.</b> </font><br /></body></html>';
$responsesubject = "Your Alert - $alert";
$responseheaders = 'MIME-Version: 1.0' . "\r\n";
$responseheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$responseheaders .= "From: $email\r\n";
$autoresponse = "$messagetop . $resmessagethanks . $messagemid . $resmessageend";
//--------------- Actual Form send -----------
if (@mail($to, $subject, $message, $headers)) {
print "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><a name=\"finished\"></a><br /><br />
 <div align=\"center\">
 <span style=\"color: #009900; font-size: 150%\">Alert has been sent!</span>
 </div><br /><br /><br />
";
//--------------- Send Auto Response -----------
mail($email, $responsesubject, $autoresponse, $responseheaders);
}
else {
print "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></a><br /><br /><br /><br /><br /><br /><br /><a name=\"finished\"><br /><br />
 <div style=\"color: #990000; font-size: 150%\" align=\"center\">
 Sorry, sending alert failed.<br />
 </div>
";
}
}
else {
}
?>

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.