This has been breaced on the forums before, bu i think my script only
needs tweaking, not rewriting, but you can school me if you know better
and I'll do what I must =P

I have a "thank you" page which processes several forms. Here's the form
it's coming from (page top and bottom snipped off, and simplified):

Code:
<form action="thank_you.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="sentpage" value="rfq">
<input type="hidden" name="attachment" value="1">
<input type="text" name="name">
<input type="text" name="email">
<input type="text" name="phone">
<input type="file" name="attachfile">
<textarea name="message" cols="26" rows="5"></textarea>
</form>



Then here's the thank you page with the PHP:
Code:
<?
$name = $HTTP_POST_VARS["name"];
$email = $HTTP_POST_VARS["email"];
$phone = $HTTP_POST_VARS["phone"];
$message = $HTTP_POST_VARS["message"];
$sentpage = $HTTP_POST_VARS["sentpage"];
$attachment = $HTTP_POST_VARS["attachment"];

if ($attachment == "1")
$filename = $HTTP_POST_FILES["attachfile"]["tmp_name"];

print $filename;

switch ($sentpage)
{
case "contact":
$pageimage = "images/component_03.jpg";
$header = "Contact Info";
$sendto = "myemailsite.com";
$subject = "Web Contact Request";
break;
case "jobs":
$pageimage = "images/component_08.jpg";
$header = "Hiring Info – Jobs";
$sendto = "myemailsite.com";
$subject = "Web Job Request";
break;
case "rfq":
$pageimage = "images/component_01.jpg";
$header = "Request for Quote";
$sendto = "myemailsite.com";
$subject = "Web RFQ Request";
break;
case "feedback":
$pageimage = "images/component_09.jpg";
$header = "Website Feedback";
$sendto = "myemailsite.com";
$subject = "Web Feedback Request";
break;
}

$body = "Name: " . trim($name) . "\nPhone: " . trim($phone) .
"\n\nMessage:\n" . trim($message);
$fromaddy = "From: ". trim($email);

if ($attachment == "1")
$fromaddy = $fromaddy . "\n" . "Content-disposition: attachment;
filename=".$filename . "\n";

mail($sendto, $subject, $body, $fromaddy);
?>

It gets there fine, messages and info intact, but no attachments or any
evidence it ever was a factor.

I either move things around and get an error, or I get an email with
nothing attached. Do I need to save the attachment somewhere before I can
put it on the email?

My logic was that the script was running, so the temp file was still
there, so if I then immediatly sent it off that would be fine. Not very
familiar with PHP ot Unix to know if that's true.

Please help I am very new to PHP, just getting back into it recently..
Thanks in advance!




##-----------------------------------------------##
Article posted from PHP Freaks NewsGroups
[url]http://www.phpfreaks.com/newsgroups[/url]
Get Addicted: php.general
##-----------------------------------------------##