You are killing me man!
How do I pass the file from one page to another?
Here is my code.
page1.php
<?php
session_start();
session_register('attachfile','attachfile_name','attachfile_type','useraddress');
echo
"
<form action='page2.php' method='post' name='proceed' enctype='multipart/form-data'>
<h1>Enter the e-mail address we should send the file to:</h2>
<h2><input type='text' name='useraddress' size='30' maxlength='50' value='$username' border='0' ></h1>
<h1>Hit the browse button to find the file you want to attach to the e-mail!
<input type='file' name='attachfile' size='16' border='0'>
<input type='submit' name='proceed' border='0' value='confirmation page'>
</form>
";
?>
page2.php
<?php
session_start();
session_register('attachfile','attachfile_name','attachfile_type','useraddress');
echo
"
Hit the submit button if you want $attachfile sent to $useraddress!
<form action='page3.php' method='post' name='submit' enctype=' multipart/form-data'>
<input type='submit' name='submit' border='0' value='submit'>
</form>";
?>
page3.php
<?php
session_start();
session_register('attachfile','attachfile_name','attachfile_type','useraddress');
function sendmsg
(
$to,
$subject,
$text,
$from,
$file,
$type,
$name
)
{
$content = fread(fopen($file,"r"),filesize($file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/plain\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n";
$header .= "--$uid\n";
$header .= "Content-Type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
mail($to, $subject, "", $header);
return true;
}
echo "An e-mail was sent to $useraddress!<br>";
echo "If you ask to print dollarsignfile, you get: $file<br>";
echo "boo<br>";
echo "If you ask to print dollarsignattachfile, you get: $attachfile";
sendmsg ($useraddress,
"Periodical - Current Issue",
"Greetings from the folks at Periodical!",
"customerservice@mywebsite.com",
$attachfile,
$attachfile_type,
$attachfile_name);
?>