Forum Moderators: coopster
In my research I have found this form, in hopes of solving a small issue.
I have a php upload script that works very well. When a user uploads a file they are asked for there username, email,filename, and a description of the file.
That part works perfect, the problem is, whenever someone uploads it notifies me via email, and that works excellent as well, except 1 problem, the from line in the email always comes up as: nobody@myhost.com.
Everything else works great, the subject, the filesize, file mime type, username, description are all sent and presented well.
How can I change this nobody@myhost.com to either the users email, or a form address such as uploads@myhost.com?
Heres the code that procesesses it all
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>upload</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff" alink="#0000ff"
topmargin="0" marginheight="0">
<?
$mailheaders="From: My Website<>\n";
$mailheaders = "File uploaded";
if ($email!= "") {
} else {
die("No email address specified.");
}
if ($superdat_name!= "") {
copy("$superdat", "/home/mysite/public_html/upload/files/$superdat_name") or
die("Couldn't copy file.");
} else {
die("No input file specified.");
}
mail("admin@mysite.com","$mailheaders", "$email\n Uploaded: $superdat_name \n Size: $superdat_size bytes \n File Type: $superdat_type \n Username :$name\n\n Message:$message");
?>
<html>
<head>
<body bgcolor=white text=black link=blue>
<!--Header/Logo-->
<p> </p>
<p> </p>
<script type="text/javascript">
<!--
window.location = "https://mysite.com/upload/success.php"
//-->
</script>
</body>
</html>
Anyways Im lost where I went wrong? and stumped, Im generally pretty good at scripting and debuging but this has me stumped.
Hopefully someone will see where i went wrong..
Thanks in advance
Robert
mail($email, $subject, $body, $headers);
Using what fromholland posted, change your mail function to:
mail("admin@mysite.com","$mailheaders", "$email\n Uploaded: $superdat_name \n Size: $superdat_size bytes \n File Type: $superdat_type \n Username :$name\n\n Message:$message","From: Name<email@address.com>");
Change the data in bold to your own data.
dc