Forums / General Questions / Adding attachments field to 'contact us' page

Adding attachments field to 'contact us' page

Locked

Views: 4,145

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
19 Feb 2008, 1:05 AM
#1
ssbeats avatar

ssbeats

New Zenner

Join Date:
Jun 2007
Posts:
72
Plugin Contributions:
0

Adding attachments field to 'contact us' page

hi there.

i want to add a feature to the contact us page where the user can send an attachement, either word doc, pdf etc, with the message.

Firstly, will the "Additional Customers field" contribution allow me to do this?

If not can someone please point me in the right direction?

I have very little experience of php but im sure if some could sugguest (perhaps in bullet points) the steps i would need to take i may be able to work it out.

Thanks.

19 Feb 2008, 3:12 PM
#2
ssbeats avatar

ssbeats

New Zenner

Join Date:
Jun 2007
Posts:
72
Plugin Contributions:
0

Re: Adding attachments field to 'contact us' page

Hi.

Essentially i want users to be able to send attachments on the contact us page.

Im not a php programmer, however i have put together the following code.

The html form code for adding an attachment will look something like this...

<?php
$db_host = "localhost";
$db_user = "myuser";
$db_pwd = "mypw";
$db_name = "CV_DB";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>

<!--- onyl display form if it has not already been submited --->
<?php
if (!isset($_POST['submit'])) {
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Upload your CV</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="stylesheet.css" type="text/css" media="screen" />
</head>
<body>
   <form name="form1" method="post"
         action="process.php" enctype="multipart/form-data">
      <table border="0" cellspacing="0" cellpadding="2">
           <tr> 
           <td>Name:</td>
         </tr>
         <tr>
        <td><input type="text" name="Name" maxlength="30" size="26" /></td>
         </tr>
          <tr>
           <td>Attatch:</td>
         </tr>
        <tr>
            <td><input type="file" name="a_file" size="16" /></td>
        </tr>
         <tr>
            <td>Message:</td>
         </tr>
         <tr>
            <td><textarea name="MsgBody" rows="6"></textarea></td>
         </tr>
         <tr>
            <td><input type="submit" name="Submit"
               value="Submit"></td>
         </tr>
      </table>
   </form>

   <?php
   $name = stripslashes($_POST['Name']);
   $a_file = $_POST['a_file'];
   $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
   mysql_query("INSERT INTO `CV_uploads` (name,CV,msg) VALUES ('$name', ‘$a_file’, '$msg')");

echo "Thank you". $name . ". We will be in contact with you shortly";
?>
</body></html>
```Firslty, is there a way of embedding this code using ez-pages?
Secondly....

I am confused about how this information gets sent to my email address after it has been inserted into the database. 
How does it work for the contact us page?


I would really appreciate some help with this.

Thanks.
19 Feb 2008, 6:16 PM
#3
ssbeats avatar

ssbeats

New Zenner

Join Date:
Jun 2007
Posts:
72
Plugin Contributions:
0

Re: Adding attachments field to 'contact us' page

just looking at the code for the zen cart contact us page....

 - tpl_contact_us_default.php
<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

<label for="enquiry"><?php echo ENTRY_ENQUIRY . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('enquiry', '30', '7', '', 'id="enquiry"'); ?>

as you can see the form field are drawn using functions such as...

zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"')
and....
zen_draw_textarea_field('enquiry', '30', '7', '', 'id="enquiry"')

Im guessing there isnt a function that deals with attachments.

So...
Can someone plese give me an indication of where i can find these functions?
Or...
Can i insert simple html form fields on this page and if so could someone tell me how to so this?

Im really really lost with this and dont seem to be getting any responses from my previous posts so please can someone help me out???? :frusty:

cheers.

19 Feb 2008, 7:13 PM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Adding attachments field to 'contact us' page

Misty's pointing you in the logical direction. My question is: - why would you want a file-upload feature on the contact-us page?

20 years a Zencart User

19 Feb 2008, 7:41 PM
#6
ssbeats avatar

ssbeats

New Zenner

Join Date:
Jun 2007
Posts:
72
Plugin Contributions:
0

Re: Adding attachments field to 'contact us' page

hi.
schoolboy - My client wants users to be able to upload CV's when applying for jobs through the site.

misty - I had a breif read through that post. Will this work for the contact us page?

Unfortunately i cant test anything as i havent yet decided if zen-cart is the best option for this site.

Thanks guys.

19 Feb 2008, 7:53 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Adding attachments field to 'contact us' page

You can do anything you want with Zen Cart, depending on your programming skill.
If it's uploading of files that you want, you can study the code used by the attributes-upload option, and model the same functionality in your contact-us page.
Emailing the attachments would be more complicated, but could be done, again with custom programming. You could just leave the files on your server somewhere and grab them when you plan to review the submitted CVs.
Or you could just post an email address for folks to submit their application+CV via email.

If Zen Cart is already running your site, and you are doing ecommerce with it, then it makes sense to stick with Zen Cart.
If you're not doing ecommerce, then maybe you don't need the power of Zen Cart on your site.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

14 Mar 2008, 10:34 AM
#8
7inter avatar

7inter

New Zenner

Join Date:
Mar 2005
Posts:
24
Plugin Contributions:
0

Re: Adding attachments field to 'contact us' page

I've tried to do this but I only receive in the e-mail the path to the file on the client computer and not the file attached.
Need to know if someone can help me to programming in order to receive the file like and e-mail attachement or if someone can giving me directions in order to know which files I need to search in and programming on them in order to get this function, file attachement, work properly.
Thank you and sorry for my english I know it's not as good as I would desire it be.

14 Mar 2008, 10:46 AM
#9
7inter avatar

7inter

New Zenner

Join Date:
Mar 2005
Posts:
24
Plugin Contributions:
0

Re: Adding attachments field to 'contact us' page

I've found in functions_email.php file, the following code:
// process attachments
$zco_notifier->notify('NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS');
// Note: $attachments_list array requires that the 'file' portion contains the full path to the file to be attached
if (EMAIL_ATTACHMENTS_ENABLED && zen_not_null($attachments_list) ) {
// if ($attachments_list == '') $attachments_list = array();
// while ( list($key, $value) = each($attachments_list)) {
// $mail->AddAttachment($value['file']); // add attachments

    $mail->AddAttachment($attachments_list['file']);          // add attachments
    //  $mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional format if specifying filename

    //     } //endwhile attach_list
  } //endif attachments
  $zco_notifier->notify('NOTIFY_EMAIL_AFTER_PROCESS_ATTACHMENTS');

someone have an idea about wich code add to the contact_us or tpl_contact_us to make file attachement work??