Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP form Mail & PHP File Upload <?php if(isset($_POST['submit'])) problem?
Old 07-20-2010, 09:03 AM PHP form Mail & PHP File Upload <?php if(isset($_POST['submit'])) problem?
Junior Talker

Posts: 3
Trades: 0
Hi, i'm new about PHP, and i try to insert the PHP Upload script in the php mail, but somehow i don't get it to work!

this actually goes to header:
Code:
<?php
  if(isset($_POST['submit'])) {
      
      $errors = array();

      $allowed_filetypes = array('.pdf','.zip','.rar'); 
      $max_filesize = 52428800; 
      $upload_path = './uploads_SS/'; 
 
   $filename = $_FILES['userfile']['name']; 
   $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); 
 
   if(!in_array($ext,$allowed_filetypes))
      $errors[] = "The file you attempted to upload is not allowed.";
 
   if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
      $errors[] = "The file you attempted to upload is too large.";
 
   if(!is_writable($upload_path))
      $errors[] = "You cannot upload to the specified directory, please CHMOD it to 777.";
 
   if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
         echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; 
      else
         echo 'There was an error during the file upload.  Please try again.'; 
 
      if($_POST['fname'] == "") {
         $errors[] = "The First Name field is empty";
      }
 
      if(count($errors) == 0) {
         $sendto = "someone@email.com";
         $title = "Application Form Submit";
         $fname = $_POST['fname'];
         $lname = $_POST['lname'];
         $Email = $_POST['Email'];
         $title_s = $_POST['title_s'];
         $dob = $_POST['dob'];
         $mob = $_POST['mob'];
         $yob = $_POST['yob'];
         $country = $_POST['country'];
         $saddress = $_POST['saddress'];
         $city = $_POST['city'];
         $zip = $_POST['zip'];
         $phone = $_POST['phone'];
         $fax = $_POST['fax'];
         $userfile = $_POST['userfile'];
         $adinfo = $_POST['adinfo'];
$message = <<<DATA
Name: $title_s $fname $lname
Email: $Email
Date of Birth: $dob, $mob, $yob
Country Territory: $country
Street Address: $saddress
City/Town: $city
Postal Code: $zip
Phone Number: $phone
Fax Number: $fax 
Attachments: $userfile
Additional information: $userfile
DATA;
         if(mail($sendto, $title, $message)) {
             $success = true;
         } else {
            $success = false;
         }
    } else {
       $success = false;

    }
  }

?>
and this in <body>
Code:
<?php
  if(isset($_POST['submit'])) {
     if($success == true && count($errors) == 0) {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;<font color='#FF0000'>Your Submission has been Completed.</font>";
     }
     if(count($errors) == 0 && $success == false && isset($_POST['submit'])) {
        echo '&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FF0000">There was a problem with our form. Please email us directly via <a href="mailto:someone@email.com">someone@email.com</a>, thank you.</font>';
     }

     if($success == false && count($errors) > 0 && isset($_POST['submit'])) {
        echo "<ul>";
        foreach($errors as $e) {
           echo "<font color='#FF0000'><li>$e</li></font>";
        }
        echo "</ul>";
     }
 }

 ?>
I know the script above isn't clean!!
but I'm new on it
thank you very much for your help!
Charles1718 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-20-2010, 01:51 PM Re: PHP form Mail & PHP File Upload <?php if(isset($_POST['submit'])) problem?
Novice Talker

Posts: 8
Name: Jenny Codner
Trades: 0
Does any errors appear? If so please post them. I've quickly skimmed the code and I don't seem to have seen any errors.
JenJenn is offline
Reply With Quote
View Public Profile
 
Old 07-21-2010, 09:16 PM Re: PHP form Mail & PHP File Upload <?php if(isset($_POST['submit'])) problem?
Average Talker

Posts: 16
Name: Filip Filipov
Location: Bulgaria
Trades: 0
Are show errors or ... what is result?
__________________

Please login or register to view this content. Registration is FREE
- IP Address Lookup. Domain Lookup. Geolocation by IP or Doomain Name

Please login or register to view this content. Registration is FREE
- Check PageRank, Alexa Rank, Backlinks, Indexed Pages, ...
primecode is offline
Reply With Quote
View Public Profile Visit primecode's homepage!
 
Reply     « Reply to PHP form Mail & PHP File Upload <?php if(isset($_POST['submit'])) problem?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33006 seconds with 11 queries