Jump to content

hhartman1027

New Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by hhartman1027

  1. Sure easy enough.  Change the $location line to this.

    $location = "upload/" . $temp[0].".".time().".".$extension;
    

    That will take the first temp array element as the start of the file name and append the current timestamp and then the extension.

    Holy cow... I need to put you on speed dial! :thumb-up:  That line worked perfectly!! Thank you, thank you, thank you! :D

  2. @possien, It would definitely be ideal to have everything saved and backed up. However, our entire site is going to be revamped in the next few months, so putting in a ton of time and effort into making that many changes... just to be wiped out soon isn't really useful. If the site wasn't going to be re-done... I would definitely go for that though! Thank you! :)

    @fastsol, I implemented the changes you suggested... with complete success!! :D :D :D I just had to increase the max file size to get it to work. THANK YOU SO MUCH!!

     

    Edit:

    Is there an easy way to assign a random number to the image name when it's saved? We're pretty sure it won't happen very often, but if, for example, user 1 uploads 2901.jpg, and then user 4 comes along and also uploads 2901.jpg. When user 4 clicks submit, it takes them to a page that says that file name already exists... but then still submits the form. Rather than having that person go back and have to change the name of their image and submit a duplicate form, it would be a lot easier if the image is just assigned a random number for it's name. Thank you! :)

  3. Thank you for the response! I have attached the functions.php file... it's kind of lengthy though! We do have a MySQL database that the rest of the website uses. As it's set up now, nothing from the form goes into the database or is saved at all. We just get an email with the user's input from the form fields. Are you thinking having the image save to the database? We hadn't thought of that! We had just been thinking that we could have the image save to an uploads folder on the server... but if the database option works, great! :)

    functions.php

  4. Hi!
    We have a form that's been used for years, and now we would like to have the added capability of attaching an image. (So a consumer can send us an image that might help with their problem.) Currently, a "confirmation" email is sent to the consumer with all of the info they gave us; a copy of the same information also goes to us. We would like the consumer's image to be saved onto our server, so when we look at the completed form, the "Image:" line has a link to that page.
    I.e. a consumer attaches an image named "picture.jpg". The copy of the information we get would have a line that reads: "Image: http://www.example.com/test/uploads/picture.jpg". I'm assuming I would use a variable to get the image name to display in order to complete the link. I'm lost about which variable I would use... but that might be because I can't get the image to even save in the folder (I think) it's supposed to. Obviously there's something messed up, but I am lost as to what that is. Any help would be greatly appreciated!

    The field to attach the image on the form:

    <label for="upload_file" class="main-label">If you have an image that would help us assist you, please attach it here.</label>
    <input type="file" name="uploaded_file">



    The process file (the attachment part is at the bottom):

    <?php
        //Collect contact form data
        //Check Special Field
        //Email ASC & Webmaster
        //Email Sender
        //Redirect to thank you page
    
        require_once($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');
    
    
        /********  CONTACT DATA **********/
        $name = stripslashes($_POST['name']);
        $company = stripslashes($_POST['company']);
        $address = stripslashes($_POST['address']);
        $city = stripslashes($_POST['city']);
        $state = stripslashes($_POST['state']);
        $zipcode = stripslashes($_POST['zipcode']);
        $country = stripslashes($_POST['country']);
        $website = $_POST['website'];
        $phone = stripslashes($_POST['phone']);
        $fax = stripslashes($_POST['fax']);
        $email = stripslashes($_POST['contact']);
        $Referred = stripslashes($_POST['referred']);
        $CustomerType = stripslashes($_POST['CustomerType']);
        $Comments = stripslashes($_POST['comments']);
        $ConsumerHelp = stripslashes($_POST['ConsumerHelp']);
        $UPC = stripslashes($_POST['UPC']);
        $Describe = stripslashes($_POST['Describe']);
        $uploaded_file = ($_FILES['uploaded_file']);
        /********  CHECK SPECIAL FIELD **********/
        $spamcheck = stripslashes($_POST['email']);
        
    
        //if spamcheck isnt blank exit page, no need for error message to user, as its a spam bot
        if ($spamcheck!=="") {
    
            exit;
    
        }
    
            
            /********  EMAIL ASC & WEBMASTER  **********/
            $message = "
        -----------------------------------------------------------------------------
           Information Inquiry
        -----------------------------------------------------------------------------
    
        $name has visited the web site and would like some information.
        The details they entered on the website are:
    
        Name: $name
        Company: $company
        Address: $address
        City: $city
        State: $state
        Zip Code: $zipcode
        Country: $country
        Website: $website
        Phone: $phone
        Fax: $fax
        Email: $email
    
        Referred to web site: $Referred
    
        CustomerType: $CustomerType
    
        Comments: $Comments
        
        I need help with: $ConsumerHelp
        
        UPC code or Item #: $UPC
        
        What I am looking for: $Describe
        
        Image: $uploaded_file
    
        Kind Regards,
    
        ";
            $email_address = "example@example";
    
            $subject = "Information Inquiry";
            $headers = "From: $name <$email>";
            $message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages
    
    
    
    
    
            /********  EMAIL SENDER **********/
            $message2 = "
        -----------------------------------------------------------------------------
          Re: Information Inquiry
        -----------------------------------------------------------------------------
    
        Thank you $name for visiting the web site. We will be using the details you entered to contact you.
    
        Name: $name
        Company: $company
        Address: $address
        City: $city
        State: $state
        Zip Code: $zipcode
        Country: $country
        Website: $website
        Phone: $phone
        Fax: $fax
        Email: $email
    
        Referred to web site: $Referred
    
        CustomerType: $CustomerType
    
        Comments: $Comments
        
        I need help with: $ConsumerHelp
        
        UPC code or Item #: $UPC
        
        What I am looking for: $Describe
        
    
        Kind Regards,
     
        ";
            $email_address2 = "$email";
            $subject2 = "Re: Information Inquiry";
            $headers2 = "From:  <example@example.com>";
            $message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages
    
        //send message 1 and save result in success var (either true for success, or false for fail
        $success = mail($email_address, $subject, $message, $headers);
    
        //conditionally send message2, no need to check success on this one
        if (strpos($email,'@aol.com') == false) {
            mail($email_address2, $subject2, $message2, $headers2);
        }
    
        if (!$success) {
        // What happens when the form does not validate
        header("Location: sorry.php");
        die ();
        } else {
          // Your code here to handle a successful verification
          header("Location: thanks.php");
            $success;
    
        }
    ?>  
    
    <?php
    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["uploaded_file"]["name"]);
    $extension = end($temp);
    
    if ((($_FILES["uploaded_file"]["type"] == "image/gif")
    || ($_FILES["uploaded_file"]["type"] == "image/jpeg")
    || ($_FILES["uploaded_file"]["type"] == "image/jpg")
    || ($_FILES["uploaded_file"]["type"] == "image/pjpeg")
    || ($_FILES["uploaded_file"]["type"] == "image/x-png")
    || ($_FILES["uploaded_file"]["type"] == "image/png"))
    && ($_FILES["uploaded_file"]["size"] < 20000)
    && in_array($extension, $allowedExts)) {
      if ($_FILES["file"]["error"] > 0) {
        echo "Return Code: " . $_FILES["uploaded_file"]["error"] . "<br>";
      } else {
        echo "Upload: " . $_FILES["uploaded_file"]["name"] . "<br>";
        echo "Type: " . $_FILES["uploaded_file"]["type"] . "<br>";
        echo "Size: " . ($_FILES["uploaded_file"]["size"] / 1024) . " kB<br>";
        echo "Temp file: " . $_FILES["uploaded_file"]["tmp_name"] . "<br>";
        if (file_exists("upload/" . $_FILES["uploaded_file"]["name"])) {
          echo $_FILES["uploaded_file"]["name"] . " already exists. ";
        } else {
          move_uploaded_file($_FILES["uploaded_file"]["tmp_name"],
          "upload/" . $_FILES["uploaded_file"]["name"]);
          echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
        }
      }
    } else {
      echo "Invalid file";
    }
    ?> 

  5. Okay, so I found out what the problem is and fixed it! The JavaScript lines below had to be moved up to be included in the $(document).ready() function. I also had to hide the DIV with CSS rather than in the JS. Woohoo!

    $("#cCustomerType-Consumer").click(function () {
        $(".ConsQ").show();
    });
    
  6. Hi!

    I've been fighting with this for a few days now and I'm really getting tired of it. If I copy and paste everything within the body tag, as well as everything in the contact.js file into JSFiddle, everything works great. When I click on "Consumer" an additional DIV of questions appears. Fantastic! However, when I take everything that's in the functioning (on JSFiddle) body tag and put it with the rest of the file, it doesn't work. I thought it wasn't connecting to the JQuery library, but when I remove that line of code, the validation (that worked before) stops working, so I don't think that's it. I'm sure it's something stupidly simple, but I'm out of ideas. Any help would be AWESOME!
    The contents of the contact.js file (the radio button part is at the bottom) can be seen on the JSFiddle.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>Have Questions?</title>
    <link rel="shortcut icon" href="/template_imgs/favicon.ico" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="../css/coastal-styles.css" rel="stylesheet" type="text/css" media="all" />
    <link href="../css/contact.css" rel="stylesheet" type="text/css" media="all" />
    <script src="../includes/jquery-1.6.4.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../includes/jquery.validate.js" type="text/javascript" charset="utf-8"></script>
    <script src="../includes/jquery.form.js" type="text/javascript" charset="utf-8"></script>
    <script src="../includes/jquery.metadata.js" type="text/javascript" charset="utf-8"></script>
    <script src="../includes/contact.js" type="text/javascript" charset="utf-8"></script>
    
    <html>
    <body>
        <div id="container">
            <?php include($_SERVER[ 'DOCUMENT_ROOT']. '/includes/header.php'); ?>
            <div class="page-heading clear" style="background-image: none; height: 20px;">
                <div class="breadcrumbs"><a href="../index.php">Home</a> > <a href="index.php">Contact Us</a>
    
                </div>
            </div>
            <div class="content">
                    <h1>Contact Us</h1>
    
                <p>Have questions? For your convenience our Customer Service Representives are available from 8:30 AM - 5:00 PM (Eastern Standard Time) Monday through Friday.</p>
                <p>All fields marked with <span class="required">*</span> are required.</p>
                <br />
                <div id="contact-form" class="floatLeft rounded-corners">
                    <form method="post" action="contact_form_process.php" id="cform" onsubmit="return validateForm()">
                        <p>
                            <label for="cname" class="main-label"><span class="required">   *   </span>Your Name</label>
                            <input id="cname" name="name" class="required" />
                        </p>
                        <p>
                            <label for="ccompany" class="main-label">Company</label>
                            <input id="ccompany" name="company" />
                        </p>
                        <p>
                            <label for="caddress" class="main-label"><span class="required">   *   </span>Address</label>
                            <input id="caddress" name="address" class="required" />
                        </p>
                        <p>
                            <label for="ccity" class="main-label"><span class="required">   *   </span>City</label>
                            <input id="ccity" name="city" class="required" />
                        </p>
                        <p>
                            <label for="cstate" class="main-label"><span class="required">   *   </span>State</label>
                            <input id="cstate" name="state" class="required" />
                        </p>
                        <p>
                            <label for="czipcode" class="main-label"><span class="required">   *   </span>Zip</label>
                            <input id="czipcode" name="zipcode" class="required" />
                        </p>
                        <p>
                            <label for="ccountry" class="main-label"><span class="required">   *   </span>Country</label>
                            <input id="ccountry" name="country" class="required" />
                        </p>
                        <p>
                            <label for="cphone" class="main-label"><span class="required">   *   </span>Phone</label>
                            <input id="cphone" name="phone" class="required" />
                        </p>
                        <p>
                            <label for="cfax" class="main-label">Fax</label>
                            <input id="cfax" name="fax" />
                        </p>
                        <p>
                            <label for="cwebsite" class="main-label">Website</label>
                            <input id="cwebsite" name="website" />
                        </p>
                        <p>
                            <label for="ccontact"><span class="required">   *   </span>E-Mail</label>
                            <input id="ccontact" name="contact" class="required email" />
                        </p>
                        <p>
                            <label for="ccomments" id="ccomments-label" class="main-label"><span class="required">   *   </span>Comments</label>
                            <textarea id="ccomments" name="comments" class="required" rows="6" cols="6"></textarea>
                        </p>
                        <p>If you are contacting us about a product, please include as much information as possible (e.g. date of purchase, description of the item and nature of problem).</p>
                        <p class="radio-questions">    <b>How did you hear about our website?</b>
    
                            <br />    <span class="radio-wrapper">
                            <label class="referred-label" for="cReferred-Search">  
                                <input type="radio" id="cReferred-Search" name="referred" value="Search_Engine"  />  
                                Search engine
                            </label>
                            <label class="referred-label" for="cReferred-Friend">  
                                <input type="radio" id="cReferred-Friend"  name="referred" value="Friend" />
                                Friend
                            </label>
                            <label class="referred-label" for="cReferred-Ad">
                                <input type="radio" id="cReferred-Ad" name="referred" value="Magazine_Ad" />
                                Magazine Ad
                            </label>
                            <label class="referred-label" for="cReferred-Packaging">
                                <input type="radio" id="cReferred-Packaging" name="referred" value="Product_Packaging" />
                                Product Packaging
                            </label>
                            <label class="referred-label" for="cReferred-Other">
                                <input type="radio" id="cReferred-Other"  name="referred" value="Other" />
                                Other
                            </label>
                            
                        </span>
    
                        </p>
                        <p>
                            <label class="radioerror error" for="referred">This field is required.</label>
                        </p>
                        <div class="clear"></div>
                        <div class="CustType" <p class="radio-questions">    <b>Check appropriate box.</b>
    
                            <br />    <span class="radio-wrapper">
                            <label class="CustomerType-label" for="cCustomerType-Consumer">  
                                <input type="radio" id="cCustomerType-Consumer" name="CustomerType" value="Consumer"  />  
                                Consumer
                            </label>
                            <label class="CustomerType-label" for="cCustomerType-Wholesale">  
                                <input type="radio" id="cCustomerType-Wholesale"  name="CustomerType" value="Wholesale" />
                                 Wholesale Distributor
                            </label>
                            <label class="CustomerType-label" for="cCustomerType-Retail_Store">
                                <input type="radio" id="cCustomerType-Retail_Store" name="CustomerType" value="Retail_Store" />
                                 Retail Store
                            </label>
                            <label class="CustomerType-label" for="cCustomerType-Mailorder">
                                <input type="radio" id="cCustomerType-Mailorder" name="CustomerType" value="Mailorder" />
                                 Mail Order Catalog
                            </label>
                            <label class="CustomerType-label" for="cCustomerType-Other">
                                <input type="radio" id="cCustomerType-Other"  name="CustomerType" value="Other" />
                                Other
                            </label>
                            
                        </span>
    
                            </p>
                        </div>
                        <p>
                            <label class="radioerror error" for="CustomerType">This field is required.</label>
                        </p>
                        <div class="ConsQ">
                            <p class="radio-questions">    <b>What can we help you with?</b>
    
                                <br />    <span class="radio-wrapper">
                                <label class="ConsumerHelp-label" for="cConsumerHelp-Use">  
                                    <input type="radio" id="cConsumerHelp-Use" name="ConsumerHelp" value="Use"  />  
                                    Proper Use of a Product
                                </label>
                                <label class="ConsumerHelp-label" for="cConsumerHelp-Sizing">  
                                    <input type="radio" id="cConsumerHelp-Sizing"  name="ConsumerHelp" value="Sizing" />
                                     Sizing Information
                                </label>
                                <label class="ConsumerHelp-label" for="cConsumerHelp-Performance">
                                    <input type="radio" id="cConsumerHelp-Performance" name="ConsumerHelp" value="Performance" />
                                     Product Didn't Perform as Expected
                                </label>
                                <label class="ConsumerHelp-label" for="cConsumerHelp-Locate">
                                    <input type="radio" id="cConsumerHelp-Locate" name="ConsumerHelp" value="Locate" />
                                     Finding Product at a Retail Location
                                </label>
                                <label class="ConsumerHelp-label" for="cConsumerHelp-Other">
                                    <input type="radio" id="cConsumerHelp-Other"  name="ConsumerHelp" value="Other" />
                                    Other
                                </label>
                                
                            </span>
    
                            </p>
                            <p>
                                <label for="cUPC" class="main-label">Please provide the UPC or Item # of the product you are referencing.</label>
                                <input id="cUPC" name="UPC" />
                            </p>
                            </br>
                            </br>
                            <p>
                                <label for="cDescribe" id="cDescribe-label" class="main-label"><span class="required">   *   </span>Please describe what you are looking for.</label>
                                <textarea id="cDescribe" name="Describe" class="required" rows="6" cols="6"></textarea>
                            </p>
                        </div>
                        <br clear="all"></br>
                        <p>Please help us fight spam.</p>
                        <p>
                            <label for="cbot" class="main-label"><span class="required">   *   </span>Please enter a number lower than 5.</label>
                            <input id="txt_qty" name="qty" class="required" />
                        </p>
                        <div class="special">
                            <input id="realemail" name="email" type="text" />
                        </div>
                        <p class="formbuttons">
                            <input name="submit" type="submit" value="Submit" />
                        </p>
                    </form>
                </div>
            </div>
    </body>
    <?php include( '../includes/footer.php'); ?>
    </html>
    
×
×
  • 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.