mail form with upload file
Hey all,
I have this mail form, with this as php code:
Code:
<?php
if ($_POST["action"] == "send"){
if ($_POST[naam] != " je naam" and $_POST[naam] != "" and $_POST[email] != " je e-mail adres" and $_POST[email] != "" and $_POST[bericht] != "") {
mail ("info@site.com", "via site",
"
Naam: ".$_POST['naam']."
E-mail: ".$_POST['email']."
Bericht: ".$_POST['bericht']."
",
"From: ".$_POST['naam']." <".$_POST['email'].">");
$subject = "je bericht aan Ceci Casariego";
$msg = "
Dit is een automatisch verzonden mail. Gelieve niet te antwoorden.
Beste $_POST[naam],
Bedankt voor je bericht aan Ceci.
Ze zal je zo snel mogelijk beantwoorden
Dit was je bericht:
$_POST[bericht]
";
mail($_POST[email], $subject, $msg);
echo 'Bedankt.<br><br>Je bericht is verzonden, <br>en je zult een bevestiging ontvangen. <br><br> <br><br>';
}
else{
echo 'Gelieve alle velden in te vullen<br><br>Je naam, email adres en bericht<br> zijn verplichte velden.<br><br><a href="contactNL.html"><font color="#565656;">[graag opnieuw]</font></a><br><br> <br>';
}
}
?>
I wish to add an upload function (attachment), like this:
Code:
<script type="text/JavaScript">
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}
</script>
<form name="form1" method="post" action="contactNL.php">
<input type="hidden" name="action" value="send">
<input type="text" name="naam" value=" je naam" onfocus="clearDefault(this)" style="border-top:0px; border-left: 1px dotted #cc6600; border-right:0px; border-bottom: 1px dotted #cc6600; width:150px">
<br>
<input type="text" name="email" value=" je email adres" onfocus="clearDefault(this)" style="border-top:0px; border-left: 1px dotted purple; border-right:0px; border-bottom: 1px dotted purple; width:150px;">
<br>
<input type="file" name="fieldname" style="border-top:0px; border-left: 1px dotted purple; border-right:0px; border-bottom: 1px dotted purple; width:150px;"><br>
<textarea name="bericht" style="border-top:0px; border-left:1px dotted #0066cc; border-right:0px; border-bottom: 1px dotted #0066cc; width:150px; height:70px" onfocus="clearDefault(this)"> je bericht</textarea>
<br>
<input type="image" src="images/sendarrow.gif" value="send">
<img src="images/clear.gif" onclick="document.getElementById('form1').reset();" style="cursor:pointer">
</form>
But when I send the mail, the attached file isn't sent. What needs to be changed in the php ?
The attachment is not oligatory; the other fields need to be filled in.
This may be blasphemous but ...
I'm a PHP newb who is trying to learn more about coding. In the past, I've used a utility called FormsToGo. It can generate the PHP code (ASP and Perl too) and provides lots of options for recipients, conformation emails, attachments, security and more. It may be easier to let FTG generate your code instead of killing yourself trying to figure out how to make your own code work. You could then examine the code FTG generates to see how it's done. I believe the publisher offers a 30 free trial.
Here is a link to the product's features page:
http://www.bebosoft.com/products/formstogo/features.php
Hope this is helpful.