Jump to content

How To Send Form Data To Email With Php


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:



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

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

<select name="item">





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

<input type="submit" />




Here's the php processing the form:




$quantity = $_POST['quantity'];

$item = $_POST['item'];


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

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





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,


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.





-Us the salt mine workers\n\n


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




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.

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.

  • Create New...