Skip to main content
Participant
Oct 23, 2019 5:49 PM UTC
Question

Linking Submit button in php to email

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 is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    Nancy OShea
    Community Expert
    Community Expert
    Oct 23, 2019 7:25 PM UTC

    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.

     

     

    Translate
    Nancy O'Shea— Product User & Community Expert
    Participant
    Oct 23, 2019 7:39 PM UTC

    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.";
    ?>

    Translate
    Nancy OShea
    Community Expert
    Community Expert
    Oct 23, 2019 11:12 PM UTC

    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.  

     

    Translate
    Nancy O'Shea— Product User & Community Expert