Jump to content

Realistic form code?


ben03

Recommended Posts

I have been working on a webform which is new to me. When testing it I discovered the host company required 2 email addresses (normal one and root) in order to validate. So I had to add the code they suggested to the sendmail.php file as seen below.

 

Will this validate and if not what would be the correct code in order for these problems to be corrected? Thanks.

 

 

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php 
mail("[email protected]", "Register Interest Form Results", $_REQUEST[message], "From: $_REQUEST[email]", "[email protected]".$_REQUEST[email]); 

$MESSAGE_BODY = "Name: ".$_POST["name"]." "; 
$MESSAGE_BODY .= "Email: ".$_POST["email"]." "; 
$MESSAGE_BODY .= "Phone: ".$_POST["phone"]." ";
$MESSAGE_BODY .= "Company: ".$_POST["company"]." ";
$MESSAGE_BODY .= "Jobtitle: ".$_POST["jobtitle"]." ";
$MESSAGE_BODY .= "Besttime2call: ".$_POST["besttime2call"]." ";
$MESSAGE_BODY .= "Howdidyouhear: ".$_POST["howdidyouhear"]." ";
$boxes = '';
if (isset($_POST['boxes']) && is_array($_POST['boxes']))
  $boxes = implode(', ', $_POST['boxes']);

$MESSAGE_BODY .= "Options: ".$boxes;


$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])." "; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure");

header( "Location: http://www.site.com/thankyou.html" ); 
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/154178-realistic-form-code/
Share on other sites

Doubtful, not sure why they would require the [email protected]

 

Have you tried it like this...

 

mail("[email protected]", "Register Interest Form Results", $_REQUEST['message'], "From: $_REQUEST['email']", "-f".$_REQUEST['email']); 

 

I generally add the -f which simply sets the "from" at the sendmail level. Which generally yields good results. If your host requires it then yes. You need it. If it does not, then no. You can omit it.

Link to comment
https://forums.phpfreaks.com/topic/154178-realistic-form-code/#findComment-810703
Share on other sites

It doesn't seem to have displayed  :'(

The hosts said you have to use the -f parameter. What do you use for that if its sent from a html page?

 

 

I have never seen a setup like that so only your host would know the correct configuration, which I assume they supplied to you and you added to the above?

 

Yes the (mail); and the (header); part at the end of the code is what they asked me to use.

 

 

Link to comment
https://forums.phpfreaks.com/topic/154178-realistic-form-code/#findComment-811565
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.