Current location: Hot Scripts Forums » Programming Languages » PHP » I've tried everything, email form problem


I've tried everything, email form problem

Reply
  #1 (permalink)  
Old 11-22-06, 03:08 PM
abul_22 abul_22 is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
I've tried everything, email form problem

Hi all,

I am a biginner so there are alot of things that you will see in the code that need to be improved...

I have a simple email form which sends information through the email.

I am trying to attach a "Reseme" to the email. I have looked through www.hotscipts.net but and I have managed to get some examples and tried to implement it to my form but they are not working.

ALL I'M TRYING TO DO IS ATTACH A RESEME TO THE EMAIL WITH ALL OTHER INFORMATION THAT IS FROM THE USER INPUT.

Any help or suggestions would be greatly appriciated. Thanx in advance.

Here are the codes I'm using.

main.php

PHP Code:

  $email $_REQUEST['Email'] ;

  
$message.= "\n"
  
$message  .= "Candidate Registration Form Results\n ";
  
$message  .= "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
  
$message.= "\n\n";
  
$message  .= "PERSONAL DETAILS\n ";
  
$message.= "\n\n"
  
$message  .= "Name: ";
  
$message .= $_REQUEST['fname'] ;
  
$message.= "\n\n";
  
$message  .= "Address: ";
  
$message .= $_REQUEST['address'] ;
  
$message.= "\n\n"
  
$message  .= "Postcode: ";
  
$message .= $_REQUEST['postcode'] ;
  
$message.= "\n\n";    
  
$message  .= "Home Tel: ";
  
$message .= $_REQUEST['htelephone'] ;
  
$message.= "\n\n";      
  
$message  .= "Mobile: ";
  
$message .= $_REQUEST['mobile'] ;
  
$message.= "\n\n";  
  
$message  .= "D.O.B: ";
  
$message .= $_REQUEST['dob'] ;
  
$message.= "\n\n";    
  
$message  .= "Age: ";
  
$message .= $_REQUEST['age'] ;
  
$message.= "\n\n"
  
$message  .= "Nationality: ";
  
$message .= $_REQUEST['nationality'] ;
  
$message.= "\n\n";      
  
$message  .= "Religion: ";
  
$message .= $_REQUEST['religion'] ;
  
$message.= "\n\n";
  
$message  .= "Work permit: ";
  
$message .= $_REQUEST['permit'] ;
  
$message.= "\n\n";
  
$message  .= "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
  
$message.= "\n\n";
  
$message  .= "EMPLOYMENT SOUGHT\n ";
  
$message.= "\n\n"
  
$message .= $_REQUEST['nanny'] ;
  
$message .= $_REQUEST['mnurse'] ; 
  
$message .= $_REQUEST['help'] ;
  
$message.= "\n"
  
$message .= $_REQUEST['permanent'] ;
  
$message .= $_REQUEST['temporary'] ;
  
$message.= "\n"
  
$message .= $_REQUEST['fulltime'] ;
  
$message .= $_REQUEST['parttime'] ;
  
$message.= "\n"
  
$message .= $_REQUEST['daily'] ;
  
$message .= $_REQUEST['livein'] ;
  
$message.= "\n\n";
  
$message  .= "Where would you like to work?: ";
  
$message .= $_REQUEST['wherework'] ;
  
$message.= "\n\n";
  
$message  .= "When can you start?: ";
  
$message .= $_REQUEST['whenstart'] ;
  
$message.= "\n\n";
  
$message  .= "preferred no. of childrend to look after: ";
  
$message .= $_REQUEST['numchildren'] ;
  
$message.= "\n\n";
  
$message  .= "Is sole charge essential?: ";
  
$message .= $_REQUEST['soleyes'] ;
  
$message .= $_REQUEST['soleno'] ;
  
$message.= "\n\n";
  
$message  .= "Ages of children preferred?: ";
  
$message .= $_REQUEST['ageprefered'] ;
  
$message.= "\n\n";
  
$message  .= "Would you be prepared to do light housework?: ";
  
$message .= $_REQUEST['houseworkyes'] ;
  
$message .= $_REQUEST['houseworkno'] ;
  
$message .= $_REQUEST['nurseonly'] ;
  
$message.= "\n\n";
  
$message  .= "Salary required: ";
  
$message .= $_REQUEST['sallaryoffered'] ;
  
$message.= "\n\n";
  
$message  .= "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
  
$message.= "\n\n"
  
$message  .= "QUALIFICATIONS OBTAINED";  
  
$message .= $_REQUEST['norland'] ;
  
$message.= "\n";
  
$message .= $_REQUEST['pc'] ;
  
$message.= "\n";
  
$message .= $_REQUEST['chiltern'] ;
  
$message.= "\n";
  
$message .= $_REQUEST['nneb'] ;
  
$message.= "\n";
  
$message .= $_REQUEST['adce'] ;
  
$message.= "\n";
  
$message .= $_REQUEST['nvq2'] ;
  
$message.= "\n";
  
$message .= $_REQUEST['nvq3'] ;  
  
$message.= "\n";
  
$message .= $_REQUEST['cache'] ;  
  
$message.= "\n";
  
$message .= $_REQUEST['btec'] ; 
  
$message.= "\n";
  
$message .= $_REQUEST['namcw'] ; 
  
$message.= "\n\n";
  


  
mail"abul_22@yahoo.co.uk""Candidate Registration Form Results",
         
$message"From: $email");
    
  
  exit;
?> 
config.php

PHP Code:

<?php


//Send Thank you confirmation -> 1=yes,2=no
$SEND_THANKS 2;

//Enable File Upload -> 1=Yes,2=No
$FILE_UPLOAD 2;

//File Storage Type -> 1= Store file, 2= Email the file (attachment), 3= Both
$FILE_DO 2;



//Allowed file extensions 1-> All
//Specify:
//$FILE_UPLOADS_EXT = array('gif','jpeg','bmp');
$FILE_UPLOADS_EXT 1;

//Maximum file size (Mega bytes)
$FILE_UPLOAD_MAX  5;

//Enalbe Image Verification -> 1=Yes,2=No
$IMAGE_VERIFICATION 2;

?>
functions.php

PHP Code:

<?php


//Function to check allowed extensions
function allowed_ext($list,$is){
    if(
$list == 1){ return true;}
    
$temp explode('.',$is);
    
$extension =  strtolower($temp[count($temp)-1]);
    return 
in_array($extension,$list);
}
?>
contact.php

PHP Code:

<?php

//Include configuration file and function file
//(default location is in the same directory)
include_once('config.php');
include_once(
'functions.php');

    
    
//File Upload checks
    
if($message == NULL && $FILE_UPLOAD == && $_FILES['user_file']['name'] != NULL){
        if(
$_FILES['user_file']['size'] > (($FILE_UPLOAD_MAX*1024)*1024)){ $message 'File is over '.$FILE_UPLOAD_MAX.' MB in size.';}
        if(
$message == NULL && allowed_ext($FILE_UPLOADS_EXT,$_FILES['user_file']['name']) == false){$message 'Invalid extension.';}
        
$new_filename date("G_i_s_").$_FILES['user_file']['name'];
    }
    

    
//End verifications, start processing
    
if($message == NULL){
        
//Check if file upload is needed
        
if($FILE_UPLOAD == && $_FILES['user_file']['name'] != NULL){
            
//Store file for keep and email
            
move_uploaded_file($_FILES['user_file']['tmp_name'],$FILE_UPLOADS_DIR.$new_filename);
        }

          
// Add file attachment to the message
                 
$new_message .= "--{$mime_boundary}\n" .
                     
"Content-Type: {$fileatt_type};\n" .
                     
" name=\"{$new_filename}\"\n" .
                     
"Content-Disposition: attachment;\n" .
                     
" filename=\"{$new_filename}\"\n" .
                     
"Content-Transfer-Encoding: base64\n\n" .
                     
$attachment_data "\n\n" .
                     
"--{$mime_boundary}--\n"
                
                unset(
$attachment_data);
            } 
            
        
if(
$message != NULL){
?>

    <?php }
    if(
$FILE_UPLOAD == 1){?>

    <?php ?>
Reply With Quote
  #2 (permalink)  
Old 11-22-06, 03:15 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
and what exactly is the problem? is the mail not recieved? is there an error?

at first sight: there are some variables not declared in this part of the code:
PHP Code:

$new_message .= "--{$mime_boundary}\n" .

                     
"Content-Type: {$fileatt_type};\n" .
                     
" name=\"{$new_filename}\"\n" .
                     
"Content-Disposition: attachment;\n" .
                     
" filename=\"{$new_filename}\"\n" .
                     
"Content-Transfer-Encoding: base64\n\n" .
                     
$attachment_data "\n\n" .
                     
"--{$mime_boundary}--\n"
there's also code missing i think. cause i don't find any usage of the main.php page.

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 11-22-06, 03:47 PM
abul_22 abul_22 is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Hi, thanx for the reply.

I am reciving the email but not the attachment.

the main.php and contact file is being called from the main html page which i have not included. Is there an simple example script anyone be able to suggest to me, i think my main problem is that i dont have sufficent PHP knowledge.

Thanx again
Reply With Quote
  #4 (permalink)  
Old 11-22-06, 04:12 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
i recommend you to use phpmailer or another class that can add attachments to emails without you having to compile them.
take a look at phpmailer or look at Email classes on phpclasses.org

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tute: Create Email based Contact Form Grabber PHP 3 05-31-06 03:11 AM
Email form problem slimey PHP 1 03-08-06 02:46 AM
PHP email form problem jcwilde1 PHP 2 06-18-05 11:19 PM
form to anyone's email with Image Verification ghostrider632 PHP 1 05-11-05 09:08 AM


All times are GMT -5. The time now is 05:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.