Jump to content

simple problem, must have a simple solution


bossman

Recommended Posts

Hello all,

 

I have recently put together a form for a client, which not only compiles the form contents into an email, but it saves a file and a date to a database. All this is complete. What i need some help on tho, is some way to figure out to have the email say "no files uploaded yet" if the user doesnt upload a file, and if they did upload a file, then it says the name of the file they uploaded.

 

So far, i have it displaying the name of the file they uploaded in the email, but if they DON'T upload a file, then it just displays a blank. I would like it to say "no files uploaded yet"

 

here is the form fields, there are two..

 

<label><strong>Please provide any applicable source materials related to copy<br/>and/or images:</strong></label><br/>
<label>Upload the file now or email to <a style="padding-left:0px;" href="mailto:[email protected]">[email protected]</a></label><br/>
<input type="file" name="upload_materials" /><br/><br/>

<label><strong>Please provide any applicable mailing lists:</strong></label><br/>
<label>Upload the file now or email to <a style="padding-left:0px;" href="mailto:[email protected]">[email protected]</a></label><br/>
<input type="file" name="upload_lists" /><br/><br/>

 

i thought adding  value="no files uploaded yet" would work, but it didn't.

 

Can anyone help me?

Well, I personally can't say at the least that I know whether or not this is a simple problem or not. Your example contains nothing more then 2 form elements. You are going to have to go more in depth with your details. Only thing I can think of at the moment, which is good practice to begin with in my own opinion, is a form handling (Error control, data scrubbing for malicious code and all that fun stuff). You can easily add that to the upload portion of your script.

i apologize for being vague. I was thikning the if statement would go on the form...i have a .php page that i wrote that handles the form, it is a big lengthy, so i will post the code relevent to the file upload functions..

 

this grabs the files from the form fields....

 

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['upload_materials']['name']); 

if(move_uploaded_file($_FILES['upload_materials']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['upload_materials']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
////////////////////////////////////////////////////
////////////////////////////////////////////////////
//BEGIN stuff to upload second file to directory
$target_path2 = "applicable_lists/";

$target_path2 = $target_path2 . basename( $_FILES['upload_lists']['name']); 

if(move_uploaded_file($_FILES['upload_lists']['tmp_name'], $target_path2)) {
    echo "The file ".  basename( $_FILES['upload_lists']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

 

this code uplodas the files to a database along with the date from the form...

 

////////////////////////////////////////////////////
//post file to database
$new_upload =$HTTP_POST_FILES['upload_materials']['name'];

$new_list=$HTTP_POST_FILES['upload_lists']['name'];

////////////////////////////////////////////////////
//query to insert files and info into database
$query = "INSERT INTO uploads (month, day, year, upload_file, upload_list)
VALUES
('$due_date_month', '$due_date_day', '$due_date_year', '$new_upload', '$new_list')";

$result=mysql_query($query);

mysql_close($link);

 

this is the code that compiles the file uploads n such to the email that is sent...

 

////////////////////////////////////////////////////
//code to call all the variables and compile the email message
$message = "<strong>Thank you</strong> for initiating a new project with JP Enterprises.<br /> We appreciate your business. The information you submited is summarized below for your review. If you need to change or update any of it, please contact me.<br /><br />
<strong>Field Marketing Manager:</strong> $field_mark_manager<br />
<strong>Company/Customer Name:</strong> $comp_cust_name<br />
<strong>ICF Source Code:</strong> $icf_source_code<br />
<strong>Lead Code:</strong> $lead_code<br />
<strong>Product Interest:</strong> $product_interest<br />
<strong>Additional Product Interest:</strong> $add_product_interest<br />
<strong>Number of Units:</strong> $number_of_units<br />
<strong>Purchase Timeline:</strong> $purchase_timeline<br />
<strong>Industry:</strong> $industry<br />
<strong>Employee Range:</strong> $employee_range<br />
<strong>Revenue Range:</strong> $revenue_range<br />
<strong>Due Date:</strong> $due_date_month $due_date_day, $due_date_year<br />
<strong>Additional Comments:</strong> $additional_comm<br /><br />
<strong>Uploaded Files:</strong><br /><br />
$new_upload<br /><br />
<strong>Uploaded Applicable Lists:</strong><br /><br />
$new_list<br /><br />
<strong>Materials Required:</strong><br /><br />";

$bottomcopy = "<br /><br />Our standard turnaround for most projects is 2-3 business days. If we have any questions for you in the meantime, we'll be in touch sooner.<br /><br />
Again, thank you for your business. We look forward to working with you to complete a successful project<br /><br />
Sincerely,<br /><br />
Scott Gebhart<br />
[email protected]<br />
724.916.3034";

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.