Skip navigation
JeffPleaseHelp
Currently Being Moderated

How Do I Tell The Send Button On A Contact Us Form To Take Info To An Email Account?

Apr 30, 2013 9:23 PM

Tags: #cs6

 

As in the Question I have built a 'Contact Us' form, although I am not sure where to put some php. script for all the details in the form to be forwarded to an email account.

 

Currently ehen I press the Send Message button in preview mode the page just refreshes itself and discards the information.

 

If not php. script, then is it possible to put "<a href="[mailto:example@email.com.au | mailto:example@email.com.au]">" somewhere in this code below?

 

<div id="Contact_Form">
  <form id="ContactForm" method="post" action="">
    <table width="670" border="1">
      <tr>
        <td><label for="FirstName"></label>
          <span id="sprytextfield1">
          First Name:<br />
          <input type="text" name="FirstName" id="FirstName" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><p>Email Address:</p></td>
      </tr>
      <tr>
        <td><label for="LastName"></label>
          <span id="sprytextfield2">
          <input type="text" name="LastName" id="LastName" />
          <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
      </tr>
      <tr>
        <td><p>Message:</p></td>
      </tr>
      <tr>
        <td><label for="Message"></label>
          <span id="sprytextarea1">
          <textarea name="Message" id="Message" cols="45" rows="5"></textarea>
          <span class="textareaRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
      </tr>
      <tr>
        <td><input type="submit" name="Submit" id="Submit" value="Send Message" /></td>  (I WAS THINKING THIS IS THE LINE THAT NEEDS ALTERING)
      </tr>
      <tr>
     
      </tr>
    </table>
  </form>
</div>

 

Any tips would be extremely useful!! Thanks

 
Replies
  • Currently Being Moderated
    Apr 30, 2013 11:28 PM   in reply to JeffPleaseHelp

    Save the below code as contact_form.php and change the email address to where you want the information to be sent. Make a thankyou.php page (this is a page the user gets taken to after submitting the message) so you can confirm to the user the email has been sent. I have not put any validation on the forms input fields because I see you are using spry validation for that.

     

     

     

    <?php

    if (array_key_exists('Submit', $_POST)) {

    $FirstName = $_POST['FirstName'];

    $EmailAddress = $_POST['EmailAddress'];

    $Message = $_POST['Message'];

     

    // Recipient/Subject/Sender

    $to = "emailAddress@yourDomainName.com";

    $subject = "Email Message";

    $sender = "From:".$_POST['EmailAddress']."\r\n";

    // The Message

    $message = "Please contact me regarding the following enquiry.\n\n";

    $message .= "Name: $FirstName\n\n";

    $message .= "Email Address: $EmailAddress\n\n";

    $message .= "Message: $Message\n\n";

     

     

    mail($to, $subject, $message, $sender);

    header("Location: thankyou.php");

    }

     

    ?>

     

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Untitled Document</title>

    </head>

     

    <body>

     

    <div id="Contact_Form">

      <form id="ContactForm" method="post" action="contact_form.php">

        <table width="670" border="1">

          <tr>

            <td><label for="FirstName"></label>

              <span id="sprytextfield1">

              First Name:<br />

              <input type="text" name="FirstName" id="FirstName" />

              <span class="textfieldRequiredMsg">A value is required.</span></span></td>

          </tr>

          <tr>

            <td><p>Email Address:</p></td>

          </tr>

          <tr>

            <td><label for="LastName"></label>

              <span id="sprytextfield2">

              <input type="text" name="EmailAddress" id="EmailAddress" />

              <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>

          </tr>

          <tr>

            <td><p>Message:</p></td>

          </tr>

          <tr>

            <td><label for="Message"></label>

              <span id="sprytextarea1">

              <textarea name="Message" id="Message" cols="45" rows="5"></textarea>

              <span class="textareaRequiredMsg">A value is required.</span></span></td>

          </tr>

          <tr>

          </tr>

          <tr>

            <td><input type="submit" name="Submit" id="Submit" value="Send Message" /></td>

          </tr>

          <tr>

     

          </tr>

        </table>

      </form>

    </div>

    </body>

    </html>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points