PDA

View Full Version : Need simple PHP form help



visitor
01 May 2010, 04:08 PM
Hi, I am trying to get my contact form working. Everything works except that when I receive the email, there is no message, just this:
Website Message:nnnname: email: website: comment: Submit:

Does anyone know why it will not send the actual message over that someone types in the form?



This is the php script I am using below, it is a free script, I don't know much about php:

form.php


<form name="contact" method="post" action="processor.php">

Name
<br />
<input name="name" type="text" size="31" id="name" />
<br />

Email
<br />
<input name="email" type="text" size="31" id="email" />
<br />

Web site
<br />
<input name="website" type="text" size="31" id="website" />
<br />

Comment
<br />
<textarea name="comment" cols="23" rows="4" id="comment" >
</textarea>
<br />
<br />

<label>
<input type="submit" name="Submit" value="Submit" />
</label>
<br />

</form>




processor.php


<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ||
!strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
die("Bad referer");
$msg="Website Message:nnn";
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $keynn";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $vnn";
}
} else {
$val = stripslashes($val);
$msg.="$key: $valnn";
}
}
$recipient="info@domain.ca";
$subject="Website Message";
error_reporting(0);
if (mail($recipient, $subject, $msg)){
header( "Location: contactformthankyou.html" );
} else
echo "An error occurred and the message could not be sent.";
} else
echo "Bad request method";
?>


phpinfo.php



<?
phpinfo();
?>