Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Beginner PHP email submit form

  • 29-08-2016 11:52am
    #1
    Registered Users, Registered Users 2 Posts: 508 ✭✭✭


    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,264 ✭✭✭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,590 ✭✭✭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