Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Beginner PHP email submit form

  • 29-08-2016 12:52PM
    #1
    Registered Users, Registered Users 2 Posts: 509 ✭✭✭


    Hi guys. I am very new to PHP and have little or no knowledge at the moment. Currently I have a live site but would like to add a email submit form that would send the users information to a certain email and number of emails. A file submit option would be handy too.

    I have tried a few pre made scripts and templates but just cant figure out how to make any of them work. I use Dreamweaver to code and manage my live site.

    Below is a picture of the message I am getting in Dreamweaver and a link to the script I am using.

    http://www.freecontactform.com/email_form.php

    scripyt.jpg


Comments

  • Registered Users, Registered Users 2 Posts: 6,271 ✭✭✭Buford T Justice


    Is the site just in html? Do you have php to use on the server?

    What's not working / what have you tried etc......


  • Registered Users, Registered Users 2 Posts: 181 ✭✭bfclancy


    i would use a simple form page with the php code for the form similar to this

    <form method="post" action="name of your php file to process the form">

    <label for="name">Name:</label><input type="text" name="name" id="name">


    <label for="email">Email:</label><input type="email" name="email" id="email">


    <label for="comments">Comments:</label><textarea name="comments" id="comments"></textarea>


    <input type="submit" name="send" value="Submit Query">

    </form>

    and the php file to process the form would contain code similar to this

    <?php
    if (isset($_POST)) {
    if (isset($_POST)) {
    $headers = "From: ".$_POST."\r\n";
    $headers .= 'Content-Type: text/plain; charset=utf-8';
    $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
    if ($email) {
    $headers .= "\r\nReply-To: $email";
    }
    $to = 'emailaddress'; // Use your own email address
    $subject = 'Site Query';
    $message = 'Name: ' . $_POST . "\r\n\r\n";
    $message .= 'Email: ' . $_POST . "\r\n\r\n";
    $message .= 'Comments: ' . $_POST;
    $success = mail($to, $subject, $message,$headers);
    }
    }
    ?>

    <?php if (isset($success) && $success) { ?>
    <h2>Thank You</h2>
    Your query has been sent. We will endeavour to respond as quickly as possible.
    <?php } else { ?>
    <h2>Oops!</h2>
    Sorry, there was a problem sending your message.
    <?php } ?>


  • Registered Users, Registered Users 2 Posts: 6,652 ✭✭✭daymobrew


    Be careful with this script as it is open to abuse and spammers.


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    Is there a reason why you are not using a pre-made script? That will avoid many security pitfalls. There are LOADS to choose from.


Advertisement