I need to create a feild on my form where people will be able to attach a photo. I already have the form created, and a .php file which sends the email and redirects them back. I have searched this forum and google, but can't seem to find a solution for this.
Here is my form code:
<form action="merchantsignup.php" method="post" id="contact_form">
<center><table width="637" border="0">
<tr>
<td>Business Name:
<br />
<input type="text" name="name" /></td>
<td>Business Phone:
<br />
<input type="text" name="phone" /></td>
<td>Business Email:
<br />
<input type="text" name="email" /></td>
</tr>
<tr>
<td>Business Address:
<br />
<input type="text" name="address" /></td>
<td>City & Zip:
<br />
<input type="text" name="city/zip" /></td>
<td>Business Webpage:
<br />
<input type="text" name="webpage" /></td>
</tr>
<tr>
<td>Main Category:
<br />
<input type="text" name="category1" /></td>
<td>Sub Category:
<br />
<input type="text" name="category2" /></td>
<td>Attach a Photo:
<br />
<input type="text" name="photo" /></td>
</tr>
<tr>
</table>
<td>
About the Business:
<br />
<textarea cols="88" rows="8" name="about"></textarea>
</h3>
<p><input type="submit" name="submit" value="Send" />
<input type="reset" name="reset" value="Clear Form" /></p>
</form>
And here is my .php file:
<?php
/* Email Variables */
$emailSubject = 'contactformprocess!';
$webMaster = 'info@lf.com';
/* Data Variables */
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city/zip'];
$webpage = $_POST['webpage'];
$category1 = $_POST['category1'];
$category2 = $_POST['category2'];
$photo = $_POST['photo'];
$about = $_POST['about'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
Address: $address <br>
City: $city <br>
Wegpage: $webpage <br>
Category1: $category1 <br>
Category2: $category2 <br>
Photo: $photo <br>
About: $about <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://lf.shtml">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">Your email will be answered soon as possible!
You will return to home in a few seconds !</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
Any input would be more than greatly appreciated!
Your current script doesn't appear to have any way of handling file:upload or sending an attached file.
What do you want to do with the photo -- load it to a folder or database on the web server? Or send it through with the email?
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
This formmailer script can handle attachments.
http://www.dbmasters.net/node/18
Using Formmailer with Attachments
http://www.dbmasters.net/node/24
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
If you're on a server that supports php, your contact form page can still be named contact.shtml.
But the script to process your form data is in a .php file.
<form action="path-to-form-on-server/form-to-email-script.php" method="post" enctype="multipart/form-data">
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
North America
Europe, Middle East and Africa
Asia Pacific