Hello all,
I've acquired a form mailer script, and have written a file upload script. Both scripts function as stand-alone scripts. However, I have a form (name, tel, email) that I am using for my file upload page. The script is intended to both:
1) display a success/thank you page to customer after file has been successfully uploaded.
2) email a notification to my company sharing customer info.
The problem I'm having is that instead of going to the error or success pages, it loads the upload script into the url and displays a blank page (ie...www.mycompany.com/upload.php)
attached is the code. Any suggestions?
<?php // upload_file.php
$mailto = 'sales_associate@mycompany.com' ;
$subject = "File Uploaded To Server" ;
$formurl = "http://www.mycompany.com/upload.html" ;
$errorurl = "http://www.mycompany.com/upload_error.html" ;
$thankyouurl = "http://www.mycompany.com/upload_thank_you.html" ;
$email_is_required = 0;
$name_is_required = 0;
$uself = 0;
$use_envsender = 0;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
if (!isset( $use_envsender )) { $use_envsender = 0 ; }
$envsender = "-f$mailto" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$contact = $_POST['contact'];
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (($email_is_required && (empty($email) || !ereg("@", $email))) || ($name_is_required && empty($name))) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (empty($email)) {
$email = $mailto ;
}
$fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n".
"Email of sender: $email\n".
"Contact Via: $contact\n".
"FIle Uploaded: $thefile\n".;
$headers =
"From: \"$name\" <$fromemail>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.13.0" .
$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
//create customer folder
$dir = $_POST['name'];
mkdir ("../customer_uploads/$dir"); //folder is created for file
if (isset($_POST['submitted'])) { //handle the form
if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "../customer_uploads/$dir/{$_FILES['thefile']['name']}")) {
mail($mailto, $subject, $messageproper, $headers );
header( "Location: $thankyouurl" );
exit ;
}
else {// error
header( "Location: $errorurl" );
exit ;
} // end error
} // end of submission if
?>