www.webdeveloper.com
Results 1 to 4 of 4

Thread: Submitting contact form

  1. #1
    Join Date
    Feb 2014
    Posts
    16

    Submitting contact form

    Hey,

    Just wondering if anyone can help me. I'm trying to get my contact form to post to my email, and also send a receipt type email to the person who filled it out. I also want them to be directed to thankyou.php after filling it out.

    I've coded and styled my form. Below is the html...


    HTML Code:
    <div class="form">
    
        <!-- Form Code Start -->
        <form class="contactForm" method="post" action="mailer.php">    
    
          <fieldset>
            <div class="details details-left">
                <label for="Name">Name *</label>
                <input class="validate[required,length[0,100]] text-input" type="text" name="Name" id="Name" />
            </div>
    
            <div class="details">
                <label for="Email">Email *</label>
                <input class="validate[required,custom[email]] text-input" type="email" name="Email" id="Email"/>
            </div>
    
            <div class="details details-left">
                <label for="Phone">Phone *</label>
                <input class="validate[required,custom[telephone]] text-input" type="text" name="Telephone" id="Telephone" />
            </div>
    
            <div class="details">
                <label for="message-title">Message Title:</label>
                <input type="text" name="subject" id="subject" />
            </div>
          </fieldset>
    
          <fielset>
            <div class="message">
                <label for="message">Message:</label> 
                <textarea rows="10" cols="50" class="validate[required,length[1,1000]] text-input" name="Enquiry" id="Enquiry"></textarea>
            </div>
          </fieldset>
    
          <fieldset>
                <input class="submit" name="submit_contact_form" type="submit" value="Submit"/>
          </fieldset>
    
        </form>
    </div>

    If anyone could help, that'd be great!

  2. #2
    Join Date
    Feb 2014
    Posts
    16
    Ok, I've got it to post to my email using the script below...

    HTML Code:
    <?php
    
    if(isset($_POST['submit']))
    
    $Name = $_POST['Name'];
    $Email = $_POST['Email'];
    $Telephone = $_POST['Telephone'];
    $Enquiry = $_POST['Enquiry'];
    
    $to = "info@beckybramwell.com"; // <<< change this to your own E-mail address
    $subject = "Website - Enquiry";
    $msg = "Name: $Name\n" . "Email: $Email\n" . "Telephone: $Telephone\n" . "Message: $Enquiry";
    
    $headers = "From: $Email" . "\r\n" .
    "Reply-To: $Email" . "\r\n" .
    "X-Mailer: PHP/" . phpversion();
    
    mail($to, $subject, $msg, $headers);
    
    echo "Thank you for contacting us! Please allow 48 hours for a representative to respond. Click <a href='contact.php'>here</a> to return to the previous page.";
    
    ?>
    Is there any way of getting it redirect to a thank you page?

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,246
    You can use the header() function to do a redirect. Just make sure it is called before any output is generated by your script.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Feb 2014
    Posts
    16
    Brill, thanks! I've managed to get that working.

    Do you know how to send a copy of the form to the user as well?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles