Forum Moderators: coopster
<?php
function pt_register()
{
$num_args = func_num_args();
$vars = array();
if ($num_args >= 2) {
$method = strtoupper(func_get_arg(0));
if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
} /* end if $method */
$varname = "HTTP_{$method}_VARS";
global ${$varname};
for ($i = 1; $i < $num_args; $i++) {
$parameter = func_get_arg($i);
if (isset(${$varname}[$parameter]))
{
global $$parameter;
$$parameter = ${$varname}[$parameter];
} /* end if isset */
} /* end for $i loop */
} /* end args >=2 */
else {
die('You must specify at least two arguments');
} /* end else */
} /* end function */
pt_register('POST','Name');
pt_register('POST','Email');
pt_register('POST','PhoneNumber');
pt_register('POST','Time');
pt_register('POST','Comments');
//Probably not a bot, process the mailing
if(strlen($Name)!=0 && htmlspecialchars($Name) == $Name){
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message = "<html><body>";
$message .= "Name: ".$Name."<br><br>";
$message .= "Email: ".$Email."<br><br>";
$message .= "Phone Number: ".$PhoneNumber."<br><br>";
$message .= "Best Time to Call: ".$Time."<br><br>";
$message .= "Comments:<br>".nl2br($Comments)."<br><br>";
$message .= "----<br>";
$message .= "This is a form-generated email sent by <a href=\"http://www.totally-bananas.net\">Totally-Bananas.net</a>.";
$message .= "</body></html>";
$message = stripslashes($message);
$message = wordwrap($message, 70);
echo $message;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: "'. $Name . '" <' . $Email . '>' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
if(mail('epheterson@gmail.com','Contact Request from Totally-Bananas.net!',$message,$headers)) {
//header("Location: http://" . $_SERVER['HTTP_HOST'] . "/thanks.php");
} else {
echo 'Dreadfully sorry, something has gone awry. Please hit your browser\'s back button and send your message manually to chuck@totally-bananas.net. You might also mention that you\'ve received this error.' . "<br />\n";
}
} else { // No name, probably a bot, throw it away...
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/nope.php");
}
?>
wordwrap($message,70)is breaking your tags apart? Instead of wordwrap() you could try just adding LF "\n" at the end of each line, where the line would logically break. Or perhaps just apply wordwrap() to your $Comments?
$Name = 'Jim Bob';
$Email = 'jim@example.com';
$PhoneNumber = '123456789';
$Time = '18:00';
$Comments = <<<EOD
This is a test. This is a test. This is a test.
This is a test. This is a test. This is a test.
This is a test. This is a test. This is a test.
This is a test. This is a test. This is a test.
EOD;
<html><body>
Name: Test Name<br><br>
Email: e@mail.com<br><br>
Phone Number: 123-456-7890<br><br>
Best Time to Call: Evening<br><br>
Comments:<br>This is a test.<br><br>
----<br>
This is a form-generated email sent by <a
href="http://www.totally-bananas.net">Totally-Bananas.net</a>.
</body></html>
<?php
$Name = 'Eric L. Pheterson';
$Email = 'eph@gmail.com';
$PhoneNumber = '123-456-7890';
$Time = 'A.M.';
$Comments = 'This is a test. Using te.php';
$message = '
Name: '.$Name.'
Email: '.$Email.'
Phone Number: '.$PhoneNumber.'
Best Time to Call: '.$Time.'
Comments:
'.$Comments.'
----
This is a form-generated email sent by www.Totally-Bananas.net.';
echo $message;
$message = wordwrap($message, 50);
//$headers = 'MIME-Version: 1.0' . "\r\n";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: "'. $Name . '" <' . $Email . '>' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
if(mail('epheterson@gmail.com.com','Contact Request from Totally-Bananas.net!',$message,$headers)) {
echo 'Supposedly, it sent?';
} else {
echo 'Dreadfully sorry, something has gone awry. Please hit your browser\'s back button and send your message manually to c@totally-bananas.net. You might also mention that you\'ve received this error.' . "<br />\n";
}
?>