You need to create a page with a form and a page for the reply. The reply page will load into the browser and an email will be sent as soon as the user submits the form.
First create a form, we will address the action to "name.php". As this is a very simple form I am not going to include a fieldset.
Matching the server-side script. You need to have elements within the form that match the php script. You need to use the "name" attribute. In the example I have used:
name="name"
name="email"
name="comments"
The property of the "name" attribute will show up in the email.
<label>Subject</label>
<input type="text" name="subject" required>
<label>Name</label>
<input type="text" name="name" required>
<label>Email</label>
<input type="email" name="email" required>
<label>Your Comments</label>
<textareatype="text" name="comments" required> </textarea>
<input type="submit" name="submit" id="submit" value="SUBMIT" />
</form>
//Must match the name attribute in your form, in this case name, email, comments. These will appear in your email:
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
//Place your email address here. The email will be sent to this address:
$to = "your email address";
// will capture the user's email address and place it as the sender's address:
$headers = "From: $email \r\n";
//Put the information that you want to appear in the subject line of the email:
$subject = 'Information for Subject Line';
//This organizes the content of the email and should match information already stated:
$body = "FROM: $name\n EMAIL: $email\n COMMENTS:\n $comments";
//Place the url for the page that will load into the browser as soon as the user submits the form:
header( "Location: name.htm" );
// The following three elements pick up the information from above for the email which includes the your email address, the user's email address, and the information for the body and the head of the email:
mail( "$to", "$subject", "$body", "$headers");
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$to = "name@company.com";
$headers = "From: $email \r\n";
$subject = 'information for the subject line';
$body = "FROM: $name\n EMAIL: $email\n COMMENTS:\n $comments";
header( "Location:name.htm" );
mail( "$to", "$subject", "$body", "$headers");
?>