Help me Modify a PHP Mail Form

edited September 2006 in Internet & Media
Hello.
This is my first post.
I am but a php novice, heck not even that, and I am looking for a php mail form that supports image attachments. I have been looking all over the internet, and the closest to something that actually works on my server is the one below, but both email addresses need to be filled out in order for it to work:
TO: webmaster@mydomain.com and FROM: buy@mydomain.com

[PHP]<?php
if(!isset($_REQUEST)){
?>
<form action="<?php $_SERVER; ?>" method="post"
enctype="multipart/form-data">
To:
<input type="text" name="to" size="40"/><br>
From:
<input type="text" name="from" size="40" /><br>
Subject:
<input type="text" name="re" size="40" /><br>
Message:
<textarea cols="30" rows="5" name="comments"></textarea><br>
Attachment:
<input type="file" name="att" size="26" /><br>
<input type="submit" name="submit" value="Send Form" />
</form>
<?php
}else{
extract($_POST);

$fp = fopen( $att, "r");

$file = fread( $fp, $att_size );

/*
Encode The Data For Transition using base64_encode();
And get a 32-character hexadecimal number
*/
$file = chunk_split(base64_encode($file));
$num = md5( time() );

/*
Define the main message headers
*/
$hdr = "From:".$_REQUEST."\r\n";
$hdr .= "MIME-Version: 1.0\r\n";
$hdr .= "Content-Type: multipart/mixed; ";
$hdr .= "boundary=".$num."\r\n";
$hdr .= "--$num\r\n";
/*
Define message section
*/
$hdr .= "Content-Type: text/plain\r\n";
$hdr .= "Content-Transfer-Encoding: 8bit\r\n\n";
$hdr .= "".$_REQUEST."\r\n";
$hdr .= "--".$num."\n";

/*
Define the attachment section
*/
$hdr .= "Content-Type:". $att_type." ";
$hdr .= "name=\"".$att_name."\"r\n";
$hdr .= "Content-Transfer-Encoding: base64\r\n";
$hdr .= "Content-Disposition: attachment; ";
$hdr .= "filename=\"".$att_name."\"\r\n\n";
$hdr .= "".$file."\r\n";
$hdr .= "--".$num."--";

/*
Send the email
*/
mail( $_REQUEST, $_REQUEST, $_REQUEST, $hdr);

/*
Close the attachment
*/
fclose( $fp );
echo "Mail sent...";
}
?>[/PHP]


I wonder if someone can help me out modifiying the code so that both addresses TO and FROM and imbedded in the php code, like this: $to = webmaster@mydomain.com and $from = buy@mydomain.com and make the following email form workable, in other words, to make it do the following:

mail( $to, $from, $_REQUEST , $_REQUEST, $_REQUEST[‘subject’], $_REQUEST, $hdr);

[PHP]<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p> </p>
<form name="form1" method="post" action="">
Your Name:
<input type="text" name="yourname" size="40"/>
<br>
Your Email:
<input type="text" name="youremail" size="40" />
<br>
Subject:
<input type="text" name="subject" size="40" />
<br>
Message:
<textarea cols="30" rows="5" name="message"></textarea>
<br>
Attachment:
<input type="file" name="att" size="26" />
<br>
<input type="submit" name="submit" value="Send Form" />
</form>
</body>
</html>[/PHP]

Please contact me if you need more info.
Thanks.
This discussion has been closed.