PDA

View Full Version : Form with attachment


rtiguy
08-05-2011, 06:17 PM
I am trying to get a form to work correctly with an attachment. The attachment can be word (.doc) for now. I am looking for the additional code that I can add to the following PHP script. If anyone has an idea of what to add and where, I'd appreciate it. Thank you.

Dreamweaver CS5.5


<?php
$subject = 'From Some Place In The World';
$emailadd = 'xxxxxx@someplaceintheworld.com;
$url = 'http://www.someplaceintheworld.com/success.html';
$req = '1';
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>