473,546 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for php mail form w/ attachments

1 New Member
Hello.
I'm working on an email form on Dreamweaver and I'm looking for a PHP code to make it work. The form with some required fields would send the submitted information and two image attachments to my email address.
I just started looking at PHP two weeks ago for an answer and the only code that worked for me, so far, was a simple php email form:
<html>
<head></head>
<body>
<?
if(isset($submi t)) {
//check for email injection attack; refuse if injection
$attack = false;
foreach($_POST as $field => $input) {
$input = stripslashes($i nput);
if(preg_match('/Content-Type: multipart\/mixed/i', $input)) $attack = true;
if($field != 'comment') {
if(preg_match('/\n/', $input)) $attack = true;
if(preg_match('/\r/', $input)) $attack = true;
}
}
if(!$attack) {
// enter the email addy you want the message sent to:
$to = "me@mail.co m";

mail($to, $subject, $comment, $name);
echo "<p>Thank you for your comment! We will respond shortly.</p>";
}
}
else {
?>
<form id="email" method="post">
<p>Name: <input type="text" id="name" name="name" size="30" maxlength="100" /></p>
<p>Subject: <input type="text" id="subject" name="subject" size="30" maxlength="100" /></p>
<p>Comment: <input type="textarea" id="comment" name="comment" cols="30" rows="10">
</p>
<p><input type="submit" name="submit" id="submit" value="Submit" /></p>
</form>
<?
}
?>

</body>
</html>

--------------------------------------------------------------------------------------------------------------------

However I am looking for a more advanced code for a form with some required fields that can send text and attachments. Any help is duly appreciated.

(here is a page I found earlier but I can't seem to make work)
http://66.102.7.104/search?q=cache:...us&ct=clnk&cd=4


here's the Dreamweaver html code for my form:

--------------------------------------------------------------------------------------------------------------------
<html>
<head>
<title>Submissi on Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFF F" text="#000000">
<form name="submissio n" method="post" action="" enctype="multip art/form-data">
<p align="center"> <font size="6" face="Gill Sans MT"><b>Submissi on Form</b></font></p>
<table width="589" border="1" cellspacing="0" cellpadding="0" height="111" bgcolor="#99999 9" bordercolor="#F FFFFF">
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font size="3" face="Gill Sans MT"><b>Your
Name </b></font><font face="Gill Sans MT"></font></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
<input type="text" name="yourname" size="30">
</font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><b><font face="Franklin Gothic Book"><b><font size="3" face="Gill Sans MT">Your
Email</font></b></font></b></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
</font><font size="3">
<input type="text" name="youremail " size="30" value="youremai l@domain.com">
</font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><b><font size="3" face="Gill Sans MT">Your
Site Name </font></b></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font size="3">
</font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
</font><font size="3">
<input type="text" name="yoursite" size="30">
</font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><b><font size="3" face="Gill Sans MT">Your
URL</font></b></font></div>
</td>
<td width="335" height="35">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font size="3">
</font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
</font><font size="3">
<input type="text" name="yoururl" size="30" value="http://">
</font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center">
<p><font face="Franklin Gothic Book"><b><font face="Gill Sans MT">Your
Number</font></b></font></p>
</div>
</td>
<td width="335" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
</font><font size="3">
<select name="yournumbe r">
<option selected>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>
</font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font></font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><b><font size="3" face="Gill Sans MT">Coordinates </font></b></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
</font><font size="3">
<input type="text" name="coordinat es" size="20" value=" i.e. A-1 or A.B-1 or A-1.2">
</font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><b><font size="3" face="Gill Sans MT">Your
Image</font><font size="3"><font size="1"><br>
</font></font></b><font size="3"><font size="1" face="Verdana"> gif -
png - jpg / jpeg files </font></font></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font size="3">
<input type="file" name="image1" size="30" value="">
<font face="Franklin Gothic Book" size="1" color="#999999" > </font></font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Franklin Gothic Book"><b><font size="3" face="Gill Sans MT">Your
Snapshot</font><font size="3"><font size="1"><br>
</font></font></b><font size="3"><font size="1"><font face="Franklin Gothic Book"><font size="3"><font size="1" face="Verdana"> jpg
/ jpeg files </font></font></font></font></font></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font face="Franklin Gothic Book"><font face="Franklin Gothic Book"></font></font><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font></font></font><font size="3">
</font><font size="3">
<input type="file" name="file2" size="30" value="">
</font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Gill Sans MT"><b>pop-up message description</b></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font size="3">
<input type="text" name="popupmess age" size="40" value="Site description -- 60 characters max." maxlength="60">
</font></div>
</td>
</tr>
<tr>
<td width="248" height="37">
<div align="center"> <font face="Gill Sans MT"><b>pop-up message<font size="3">
color BG</font></b></font></div>
</td>
<td width="335" height="37">
<div align="center"> <font size="3">
<select name="popupcolo rs">
<option selected>yellow hue</option>
<option>blue hue</option>
<option>red hue</option>
<option>green hue</option>
<option>orang e hue</option>
<option>pink tint</option>
<option>purpl e hue</option>
<option>brown hue</option>
<option>beige tint</option>
<option>gray shade</option>
<option>plain white</option>
</select>
</font></div>
</td>
</tr>
</table>
<hr>
<div align="left">
<p>
<input type="checkbox" value="checkbox " name="checkthis box">
Check this box.<font color="#FF0000" size="2">*</font></p>
<p align="center">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="clear" value="Reset">
</p>
<p><font face="Franklin Gothic Book"><font face="Franklin Gothic Book"><font color="#FF0000" size="1">*</font></font></font>
<font size="1" face="Trebuchet MS">required fields</font></p>
</div>
<div align="center">
<hr>
<p>&nbsp; </p>
</div>
</form>
<p>&nbsp; </p>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------

Thank you in advance.
SL999.
Aug 11 '06 #1
1 3494
ronverdonk
4,258 Recognized Expert Specialist
If you want to write everything yourself, that's fine. But I would suggest that you have a look at the various email classes available at www.phpclasses. org, e.g. the libMail class at link http://www.phpclasses.org/browse/package/1458.html

Excerpts from the description:
This is class is an enhanced version of Leo West libMail.

The class has some improvements setting recipients with To, CC, BCC, setting the return path address and attaching files to the message

The class also provides some anti-spamming precautions by setting some headers that identify the IP address of the machine of the user accessing the current script page.
Ronald :cool:
Aug 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2442
by: S_p_ike | last post by:
Hi all, I have a problem with mail with attachments. To send e-mail with attachments from a form, I use Setec Astronomy's libmail class (v 1.4) (available here http://www.phpclasses.org/) Everything is ok but if I use a specific e-mail address (say address X) in the field To, the e-mail arrives without attachments. (even if I use two...
1
2392
by: praba kar | last post by:
Dear All, I am new to python world. I have pasted my code which I used it to build rfc822 format mails for webbased mailing system task(which is like to yahoo.com web interface). Now I am asking some suggestions and guidence regarding this below code. Still What way I can improve this code. If anyone find error kindly let me know how to...
11
308
by: Ron Vecchi | last post by:
I've used System.Web.Mail before but have never had the need to send attchemnets through it...until now. A client of mine would like a form on the website to allow a user to type up a message and upload a file. I'm staying away from mailto links. So the file and message will be uploaded to the server when the user clicks send. The new...
3
5680
by: Tim T | last post by:
Hi, I hope there is someone reading this that has the answer, Please Help! I have the need to send a html email via asp.net. its easy enough to send an html email and add attachments. My question is, how to you set the Content-Location of each attachment in the mail headers so that the images are embedded in the html email rather than...
4
2008
by: tony | last post by:
I'm designing a survey form page that will be fairly complex and am becoming confident enough with PHP now to tackle most things. (Thanks to everyone here who has helped) Before I go too far with this I was wondering if anyone could perhaps offer advice or point me to any documents/web pages that could help with ensuring the security of the...
5
2357
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav files) or images (bmp, gif or tiff) I can send the email messages OK but the attachments are giving me grief. Can anyone provide some code that...
1
6824
by: maxxxxel | last post by:
Hi Can anyone help me with some asp code , I changed the code to use CDO.message instead of the old cdont.sys to send mail from a ASP webpage which works fine. Our problem is that when we send mail externally to a internet email site like Gmail the PDF is sent but is corrupted because CDOSYS ends up using binary encoding rather than Base64...
3
2388
by: raj200809 | last post by:
when i m sending mail i received error from symantec Antivirus" Your email message was unable to be sent because your mail server rejected the message 550-5.7.1 the ip you’re using to send mail is not authorized" i have configure smtp server put 127.0.0.1 ip in relay and also put 127.0.0.1 ip in connection. using System; using...
7
16878
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
0
7504
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.