Page 1 of 7 123 ... LastLast
Results 1 to 10 of 63

Thread: PHP email form for dummies???

  1. #1
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default PHP email form for dummies???

    I am working a site for a client and I am a newb to web design and development... so talk slowly and at like a 3rd grade level.

    So, I am trying to make an email form - I have designed the form in HTML on my contact page http://gscapedesign.com/contact_us.html

    I also created a php file - email_form.php (which I have no idea what I did there... I "hacked" from a tutorial and inserted what I thought was right and relevant to my situation). That said, when the form is completed, an error message comes up reading Parse error: syntax error, unexpected T_CONCAT_EQUAL in /home/content/95/8124395/html/email_form.php on line 17
    Code:
    <?php
    $to = "josh@gscapedesign.com";
    $subject = "Greenscape Customer Inquiry";
    $message = "Customer name: " . $_POST['name'] . "\r\n" .
    "Phone number:			" . $_POST['phone'] . "\r\n" .
    "Email:					" . $_POST['email'] . "\r\n" ."\r\n" .
    "Contact: 				" . $_POST['contact'] . "\r\n" ."\r\n" .
    "Services:				" . $_POST['landscape design and construction'] . "\r\n" .
    "Services:				" . $_POST['hardscape design and construction'] . "\r\n" .
    "Services:				" . $_POST['grounds maintenance'] . "\r\n" .
    "Services:				" . $_POST['irrigation and drainage systems'] . "\r\n" .
    "Services:				" . $_POST['lighting'] . "\r\n" .
    "Budget:				" . $_POST['budget'] . "\r\n" . 
     
    $from = $_POST['email'];
    $headers = "From: $from" . "\r\n";
    $headers = .= "Bcc: kroge16@tigers.lsu.edu" . "\r\n" ;
    mail($to,$subject,$message,$headers) ;
    ?>
    Any pointers???
    Last edited by katiebugla; 08-25-2011 at 05:23 PM.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Can you please post your code?
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Did you need the html or php?

    Or did you need something else?

    Sorry I'm such a newb... I'm stumbling through all these languages.

  4. #4
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    HTML Code:
        <form action="email_form.php" method="post" name="contact_gscape" id="contact_gscape">
          <span id="sprytextfield1">
          <label for="name"><span class="form_text">Name</span></label>
          <input type="text" name="name" id="name" />
          <span class="textfieldRequiredMsg">A contact name is required.</span></span>
          <br />
          <span id="sprytextfield2">
          <label for="phone" class="form_text">Phone Number</label>
          <input type="text" name="phone" id="phone" />
          <span class="textfieldRequiredMsg">A phone number is required.</span><span class="textfieldInvalidFormatMsg">Please enter a valid phone number.</span></span>
          <br />
          <span id="sprytextfield3">
          <label for="email" class="form_text">Email</label>
          <input type="text" name="email" id="email" />
          <span class="textfieldRequiredMsg">An email address is required.</span><span class="textfieldInvalidFormatMsg">Please enter a valid email address.</span></span>
          </p>
          <span id="contact">
          <label for="label">What is the best way to contact you?</label>
          <select name="contact" size="1" id="contact">
            <option value="Phone">Phone</option>
            <option value="Email">Email</option>
          </select>
          <span class="selectRequiredMsg">Please select an item.</span></span>
          </p>
            <span class="form_text">What Greenscape services would you like to know more about?</span>      
            <br />
           <label>
           	  <input name="landscape design and construction" type="checkbox" id="landscape design and construction" value="landscape design and construction" />
              <span class="form_text">Landscape Design &amp; Construction</span></label>
               <br />
           <label>
           	  <input name="hardscape design and construction" type="checkbox" id="hardscape design and construction" value="hardscape design and construction" />
              <span class="form_text">Hardscape Design &amp; Construction</span></label>
              <br />
          <label>
           	  <input name="grounds maintenance" type="checkbox" id="grounds maintenance" value="grounds maintenance" />
              <span class="form_text">Grounds Maintenance</span></label>
              <br />
          <label>
           	  <input name="irrigation and drainage systems" type="checkbox" id="irrigation and drainage systems" value="irrigation and drainage systems" />
              <span class="form_text">Irrigation &amp; Drainage Systems</span></label>
             <br />    
          <label>
           	  <input name="lighting" type="checkbox" id="lighting" value="lighting" />
              <span class="form_text">Lighting</span></label>
            </p>
             <span class="form_text">What is your budget?</span>
             <label for="budget"></label>
             <select name="budget" id="budget">
               <option value="level1">$0 - $500</option>
               <option value="level2">$501-$1000</option>
               <option value="level3">$1001-$5000</option>
               <option value="level4">$5000+</option>
             </select>
             <span class="selectRequiredMsg">Please select an item.</span></span>
            </p>
            <span id="sprytextarea1">
            <label for="other" class="form_text">Anything else?</label>
            <br />
            <textarea name="other" id="other" cols="45" rows="2"></textarea>
            <span class="textareaRequiredMsg">A value is required.</span></span><br />
          <input name="Submit" type="submit" value="Email Us" />
      </form>

  5. #5
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Sorry, I meant the PHP.
    Corrections to my coding/thoughts welcome.

  6. #6
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Your syntax error is on this line:
    PHP Code:
    $headers = .= "Bcc: kroge16@tigers.lsu.edu" "\r\n" 

    You put "= .=" by accident. It should only be ".=".

    Change that line to this:
    PHP Code:
    $headers .= "Bcc: kroge16@tigers.lsu.edu" "\r\n" 
    And you should be fine.
    - Josh

  7. The Following User Says Thank You to JShor For This Useful Post:

    katiebugla (08-25-2011)

  8. #7
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    It did indeed!!! THANK YOU!

  9. #8
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I have more questions - if y'all don't mind. When the company receives the emailed form this is what they get

    Customer name: Katie Rogers
    Phone number: 1-555-555-5555
    Email: katiebugla@yahoo.com

    Best way to contact: Phone

    Services:
    Services:
    Services:
    Services:
    Services: lighting
    Budget: level1


    I would like it to just display the services people selected (please see page for reference http://gscapedesign.com/contact_us.html)

    Thoughts??? Thank you!
    Last edited by katiebugla; 08-26-2011 at 03:26 PM.

  10. #9
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Create an array with each POST value, looping through them and checking if they're filled out should work.

    PHP Code:
    <?php
    $to 
    "josh@gscapedesign.com";
    $subject "Greenscape Customer Inquiry";
    $message "Customer name: " $_POST['name'] . "\r\n" .
    "Phone number:            " $_POST['phone'] . "\r\n" .
    "Email:                    " $_POST['email'] . "\r\n" ."\r\n" .
    "Contact:                 " $_POST['contact'] . "\r\n" ."\r\n";

    $field = array('landscape design and construction''hardscape design and construction''grounds maintenance''irrigation and drainage systems''lighting''budget');

    foreach(
    $field as $f) {
    if(
    $_POST[$f] != '' && isset($_POST[$f])) {
    $message .= "Services: ".$_POST[$f]."\r\n";
    }
    }

    $message .= "Budget:                " $_POST['budget'] . "\r\n" 
     
    $from $_POST['email'];
    $headers "From: $from"\r\n";
    $headers "Bcc: kroge16@tigers.lsu.edu" "\r\n" ;
    mail($to,$subject,$message,$headers) ;
    ?>
    - Josh

  11. The Following User Says Thank You to JShor For This Useful Post:

    katiebugla (08-26-2011)

  12. #10
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Thank you JShor, you have been a tremendous help... I owe you!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •