0

I made a PHP script for a form, but dont't know how to get it to work...How do i put the PHP in the page and make it active? I am a total noob to php, so i have no idea. Do you put the php inside the HTML doc, or make a separate PHP document and link to that? The PHP thing is here, in case you need it.

<?php 
$ToEmail = '[email protected]'; 
$EmailSubject = 'Site contact form '; 
$mailheader = "From: ".$_POST["email"]."\r\n"; 
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>"; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?>
1
  • This needs a form to be posted to it. <form action="test.php" method="POST">. Commented Feb 17, 2012 at 20:37

2 Answers 2

4

The easiest thing to do would be to create a separate PHP page (e.g. send.php) and then have the form in your HTML page use it in the action attribute (e.g. <form method="post" action="send.php">)

Sign up to request clarification or add additional context in comments.

Comments

-3

put it at the top of the .php file which contains the html code if you want it to work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.