Skip to main content
Known Participant
October 23, 2023
Question

help with a very simple form script

  • October 23, 2023
  • 1 reply
  • 165 views

I just need a very simple script
send to : me@me.com
form field: name
form field : message

after success to: thankyou.html

no email address is entered (they are children)
the email that is received
it will look like this
letter from: (child's name)
he writes: (text message)

 

my formmail code:

<?php

//Create Variable Names
$name = trim($_POST['naam']);
$email = trim($_POST['email']);
$subject = StripSlashes($_POST['subject']);
$message = StripSlashes($_POST['bericht']);
   
//Clear variables
$name = "";
$email = "";
$subject = "";
$message = "";   
   
if(!empty($HTTP_POST_VARS['name']) || !empty($HTTP_POST_VARS['email'])){

$to = "vivke@telenet.be";   
$subject = "Sinterklaas";
$body .= "\n\n";
$body .= "This email is send by: " . $HTTP_POST_VARS['name'] . " \n\n<" . $HTTP_POST_VARS['email']  . ">\n\n";
$body .= "" . $HTTP_POST_VARS['message'] . "\n";
$body .= "\n";

$header = "From: " . $HTTP_POST_VARS['name'] . " <" . $HTTP_POST_VARS['email'] . ">\n";
$header .= "Reply-To: " . $HTTP_POST_VARS['name'] . " <" . $HTTP_POST_VARS['email'] . ">\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";

		if(mail($to, $subject, $body, $header)){
			echo "Sent";
			}
		else {
			echo "Error";
		}
} 	
else {
	echo "Error";
}
   


$to = ($HTTP_POST_VARS['email']);   
$subject = "website email";
$body = "Dear " . ($HTTP_POST_VARS['name']);
$body .= ",";
$body .= "\n\nThank you for your email. \n\nWe will surely read it, but because we receive so many mails, the answer\nsometimes may take a couple of days.\n\nToker \n";
$body .= "\n\n";
   
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";
if(mail($to, $subject, $body, $header))
   
//redirect to the 'thank you' page
header('Location: danku.html');
?>

 I receive an eror, what do I wrong?

 

my formcode

<form action="formscript.php" method="post" name="form1" id="form1">
  <p>Jouw naam:
    <textarea name="naam" class="naambox" id="naam"></textarea>
  </p>
  <p>Jouw bericht aan Sinterklaas</p>
  <p>
    <textarea name="bericht" maxlength="500"  class="berichtbox" id="bericht"></textarea>
  </p>
  <p>&nbsp;</p>  <p>
    <input name="email" type="hidden" id="email" value="vivke@telenet.be">
  </p>
  <p> 

 

This topic has been closed for replies.

1 reply

Nancy OShea
Community Expert
Community Expert
October 23, 2023
Nancy O'Shea— Product User & Community Expert