Jump to content

How To Send Form Data To Email With Php


Aloha

Recommended Posts

My name is Sarah. I am new to php. I found a sample php script I'd like to use which sends user-entered data from an HTML form to another page, which gets processed there with php. But I don't know how to also get the form results emailed to me. Here's what I mean:

 

Here's the HTML Form:

 

<html><body>

<h4>Tizag Art Supply Order Form</h4>

<form action="process.php" method="post">

<select name="item">

<option>Paint</option>

<option>Brushes</option>

<option>Erasers</option>

</select>

Quantity: <input name="quantity" type="text" />

<input type="submit" />

</form>

</body></html>

 

Here's the php processing the form:

 

<html><body>

<?php

$quantity = $_POST['quantity'];

$item = $_POST['item'];

 

echo "You ordered ". $quantity . " " . $item . ".<br />";

echo "Thank you for ordering from Tizag Art Supplies!";

 

?>

</body></html>

 

But I would also like to have the user entered data emailed to me. Can anyone help or show me how to do it?

 

Thank you,

Sarah

Link to comment
Share on other sites

Hi Sarah;

I think something like this would work.

 

 

// send email Notification

$to = "To: youremailaddress@your.domain";

$subject = "text written here appears in the subject head of the email";

 

 

$body = "Dear Sarah;\n

Below are items we need, yada yada. Text written here will appear in the body of the email.

 

 

 

Sincerely,

-Us the salt mine workers\n\n

 

---Details about what your form captured can go here like this---

CUSTOMERS NAME: $name

CUSTOMERS EMAIL: $email

---ABOUT YOUR ORDER---

QUANTITY: $quantity

ITEM: $item";

 

$headers = "From: $email";

 

mail($to, $subject, $body, $headers);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...