[Support request]
[Support request]
This topic is: not resolved

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Eldo 2 years, 4 months ago.


  • studio9designsa
    Participant
    | #8651

    Good day,

    I have added an extra contact form and modified it but it does not work,

    You can view the form here:

    http://site7.webdemo.co.za/sign-up.html
    I have named this contact form "signup.php"

    The code for the PHP Form is as follows :

    <?php

    /* ========================== Define variables ========================== */

    #Your e-mail address
    define("__TO__", "duane@studio9deisgn.co.za");

    #Message subject
    define("__SUBJECT__", "Sign UP Form = From:");

    #Success message
    define('__SUCCESS_MESSAGE__', "Your message has been sent. Thank you!");

    #Error message
    define('__ERROR_MESSAGE__', "Error, your message hasn't been sent");

    #Messege when one or more fields are empty
    define('__MESSAGE_EMPTY_FILDS__', "Please fill out all fields");

    /* ======================== End Define variables ======================== */

    //Check e-mail validation
    function check_email($email){
    if(!@eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
    return false;
    } else {
    return true;
    }
    }

    //Get post data
    if(isset($_POST['themeple_contact']) and isset($_POST['themeple_name']) and isset($_POST['themeple_email'])){
    $name = $_POST['themeple_name'];
    $mail = $_POST['themeple_email'];
    $contact = $_POST['themeple_contact'];

    if($name == '') {
    echo json_encode(array('info' => 'error', 'msg' => "Please enter your name."));
    exit();
    } else if($mail == '' or check_email($mail) == false){
    echo json_encode(array('info' => 'error', 'msg' => "Please enter valid e-mail."));
    exit();
    } else if($contact == ''){
    echo json_encode(array('info' => 'error', 'msg' => "Please enter your contact number."));
    exit();
    } else {
    //Send Mail
    $to = __TO__;
    $subject = __SUBJECT__ . ' ' . $name;
    $contact = '
    <html>
    <head>
    <title>Mail from '. $name .'</title>
    </head>
    <body>
    <table style="width: 500px; font-family: arial; font-size: 14px;" border="0">
    <tr style="height: 32px;">
    <th align="right" style="width:150px; padding-right:5px;">Name:</th>
    <td align="left" style="padding-left:5px; line-height: 20px;">'. $name .'</td>
    </tr>
    <tr style="height: 32px;">
    <th align="right" style="width:150px; padding-right:5px;">E-mail:</th>
    <td align="left" style="padding-left:5px; line-height: 20px;">'. $mail .'</td>
    </tr>
    <tr style="height: 32px;">
    <th align="right" style="width:150px; padding-right:5px;">Subject:</th>
    <td align="left" style="padding-left:5px; line-height: 20px;">'. $contact .'</td>
    </tr>
    </table>
    </body>
    </html>
    ';

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
    $headers .= 'From: ' . $mail . "\r\n";

    if(mail($to,$subject,$contact,$headers)){

    echo json_encode(array('info' => __SUCCESS_MESSAGE__));
    }
    else echo json_encode(array('info' => __ERROR_MESSAGE__));
    }
    } else {
    echo json_encode(array('info' => 'error', 'msg' => __MESSAGE_EMPTY_FILDS__));
    }
    ?>


  • Eldo
    Keymaster
    Post count: 6788
    | #8713

    Replies only viewable for logged in users

You must be logged in to reply to this topic.