Welcome to Interactive Programming Forums, where you can ask questions, receive answers from other members of the community, post code snippets and post exercies.

Adding correct action command to send email

+15 votes
I am a newbie so please bear with me ... I am editing a template but cannot get the submit button to send an email directly. The only command I get to work is for the the default email client to open and then the person can complete and send. Here is a copy of the script - I need the command (php?) to replace the # at the action command:
<form id="contact" method="post" action="#">
        <div class="row1">
          <span class="formlabel">your name</span>
          <span class="forminput"><input type="text" /></span>
        </div>
        <div class="row1">
          <span class="formlabel">your email address</span>
          <span class="forminput"><input type="text" /></span>
        </div>
        <div class="row1">
          <span class="formlabel">your enquiry</span>
          <span class="forminput"><textarea cols="28" rows="11" class="textarea"></textarea></span>
        </div>
        <div class="spacer">&nbsp;</div>
        <div class="row1">
          <span class="formlabel"></span>
          <span class="forminput"><input type="submit" value="submit" class="submit" /></span>
        </div>
      </form>

Thank you in anticipation ...
posted 12 years ago in CSS by freekstegmann (1,920 points)

1 Answer

+1 vote
Hello  freekstegmann,

Example:

action="email.php"

email.php will $_POST all forms input and validate them, after validation do:

<?php
$header = "From: ". $mail_from . " <" . $mail_subject . ">\r\n";
mail($mail_to,$mail_subject,$email_body,$header);
$error_msg="E-mail has been sent successfully to Yourwebside.com.";
header("Location: contact.php?error_msg=$error_msg");
?>
answered 12 years ago by vlad36 (7,400 points)

Related questions

+10 votes
1 answer
posted 12 years ago in Ruby by jampart (2,250 points)
+7 votes
1 answer
posted 12 years ago in CSS by friskyding0 (1,940 points)
+19 votes
1 answer
posted 13 years ago in CSS by Mtata D Mtatuz (1,490 points)
+14 votes
0 answers
posted 13 years ago in CSS by Abdulqadir Farhang (260 points)
+3 votes
1 answer
posted 11 years ago in Javascript by James Dana Hanson (1,450 points)