02-18-2010, 09:06 PM
|
#8 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
Your upload.php should look something like this.
php Code:
$to = "e [email]mail@hotmail.com[/email]"; $subject = "New template!"; $filename = str_replace(" ", "%20", $filename); $email = $_POST[ 'email']; // Run a simple check on the email.if ($email == '') { // Throw some sort of error, either a die() or don't upload the file.}// Just do simple check for one "@" sign.if (! preg_match("/[@]{1}/", $email)) { // It's debatable if you should throw a visible error here. // Validating emails with a regex is very difficult, and you/we/whoever // might miss something that would throw out perfectly good emails.}$body = 'New template has been uploaded! ' . $urlloc . $filename . "\n"; $body .= 'The file was uploaded by: ' . $email; $headers = "From: email.com\r\nX-Mailer: php"; // This is just my preference here, I like to have the main() call// on its own line.$sent_mail = mail($to, $subject, $body, $headers); if ($sent_mail) { echo("<p>A notification has been sent to the site and your template will be added ASAP!</p>"); } else { echo("<p>Message delivery failed...</p>"); }
If you do decide to throw visible errors then make sure to encapsulate the mail() in an if statement which would stop it from sending the message (and possibly the file upload, depending on how you set it all up).
|
|
|
|