Skip to main content
Participant
October 23, 2019
Question

Linking Submit button in php to email

  • October 23, 2019
  • 1 reply
  • 253 views

Hello.  Trying to link the Submit button in  a action.php doc to my agency's email.  Form working OK, echo message OK.  Who can steer me in the right direction?  Willing to share my code if necessary.

    This topic has been closed for replies.

    1 reply

    Nancy OShea
    Community Expert
    Community Expert
    October 23, 2019

    See this 3 part tutorial.  

    https://alt-web.blogspot.com/2015/07/responsive-contact-form-with-bootstrap.html

     

    NOTE:  For this to work, your hosting server must support PHP mail () function. And your contact form must be saved as a PHP file.  If your host doesn't support the mail function, you'll need to ask them which scripts they recommend you use.

     

     

    Nancy O'Shea— Product User & Community Expert
    Participant
    October 23, 2019

    Thank you Nancy.  Contacted my server host to check.  Waiting for a posirtive answer.

    Meanwhile,here is my code.

     

    <!doctype php>
    <?php
    if(lissett($POST_['submit']))
    $to = "myname@myagency.ca";
    $subject= 'Contact Form Submit';
    $email_message= 'Quick Request Submission:\n\n';

     

    mail ($email, $request, $message, "From:".$from);

    $name = $_POST['Your Name'];
    $email = $_POST['Your email'];
    $request = $_POST['Request'];
    $message = $_POST['Message'];

    $email_from = "myname@myagency.ca';
    $email_subject = 'New Request Submssion'
    $email_body = "You have received a new message from $name.\n".
    "Here is the message:\n $message".

    <form action="http://newavenues.ca/request_form.php"

    $subject = "Information Request";
    print "This is an automated message from (Agency name inc.). Your message has been sent. Please do not reply to this email.";
    ?>

    Nancy OShea
    Community Expert
    Community Expert
    October 23, 2019

    That is not a contact form and that script is not secure.    

    Please read my 3 part tutorial from start to end.  It's very important to validate and sanitize  data before it ever reaches your server.  

     

    Nancy O'Shea— Product User & Community Expert