PHP form to email thank you page

Discussion in 'General troubleshooting' started by Debbie, Aug 31, 2014.

  1. Hi,
    my form to email does work, I just want an event to happen when you click submit. When a user clicks submit, I want them to be taken to a thank you page. I created a success.html page but am not sure how to code it in so this event occurs. Here is my code, I will leave out password and personal email information. Thank you. :)

    <?php
    require_once "Mail.php";
    if (isset($_POST['submit'])) {
    // get name
    $name = trim($_POST['name']);
    // get email address
    $email = trim($_POST['email']);
    // get comments
    $comments = $_POST['comments'];
    $comments = trim($comments);
    $comments = stripslashes($comments);
    $comments = htmlspecialchars($comments);
    }
    $from = $_POST['email'];
    $to = "Me <[email protected]>";
    $subject = "Comments from website";
    $body = $_POST['comments'];
    $host = "mail.domain.com";
    $username = "[email protected]";
    $password = "password";
    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));
    $mail = $smtp->send($to, $headers, $body);


    // check antiSpam field
    $antiSpam = trim($_POST['antiSpam']);

    if (!empty($antiSpam)) {

    exit;

    }


    ?>
     
  2. ComputerMan

    ComputerMan Winhost Staff

  3. Thank you, those articles are great. I was able to fix this issue. Thanks.
     
    ComputerMan and patrickcasey like this.

Share This Page