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

+12 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 1 year ago in CSS by freekstegmann (1,840 points)

1 Answer

0 votes
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 6 months ago by vlad36 (7,210 points)

Related questions

+10 votes
1 answer
posted 1 year ago in Ruby by jampart (2,250 points)
+7 votes
1 answer
posted 1 year ago in CSS by friskyding0 (1,940 points)
+19 votes
1 answer
posted 1 year ago in CSS by Mtata D Mtatuz (1,490 points)
+12 votes
0 answers
posted 1 year ago in CSS by Abdulqadir Farhang (200 points)
+2 votes
0 answers
posted 7 months ago in XML by yende (8,120 points)