Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End contact form not working……

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #43685

    Dear Friends,
    Please check this link http://test.pak-energy.com/contacts.html this form is not working please help me for my friend.
    Thanks

    #129790

    sorry the subject is “Contact form Not Working……”

    #129792

    he told me there is no any php file on the web server, he asked, how to create a new contact-form.php ??? for this contact form.

    #129793

    $subject = “Feedback from WEBSITE” ;
    $formurl = “URL” ;
    $thankyouurl = “URL” ;
    $errorurl = “URL” ;

    $email_is_required = 1;
    $name_is_required = 1;
    $comments_is_required = 1;
    $uself = 0;
    $forcelf = 0;
    $use_envsender = 0;
    $use_sendmailfrom = 0;
    $smtp_server_win = ” ;
    $use_webmaster_email_for_from = 0;
    $use_utf8 = 1;
    $my_recaptcha_private_key = ” ;

    //


    END OF CONFIGURABLE SECTION



    define( ‘MAX_LINE_LENGTH’, 998 );
    $headersep = $uself ? “n” : “rn” ;
    $content_nl = $forcelf ? “n” : (defined(‘PHP_EOL’) ? PHP_EOL : “n”) ;
    $content_type = $use_utf8 ? ‘Content-Type: text/plain; charset=”utf-8″‘ : ‘Content-Type: text/plain; charset=”iso-8859-1″‘ ;
    if ($use_sendmailfrom) {
    ini_set( ‘sendmail_from’, $mailto );
    }
    if (strlen($smtp_server_win)) {
    ini_set( ‘SMTP’, $smtp_server_win );
    }
    $envsender = “-f$mailto” ;
    $fullname = isset($_POST) ? $_POST : $_POST ;
    $email = $_POST ;
    $comments = $_POST ;
    $http_referrer = getenv( “HTTP_REFERER” );

    if (!isset($_POST)) {
    header( “Location: $formurl” );
    exit ;
    }
    if (($email_is_required && (empty($email) || !preg_match(‘/@/’, $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {
    header( “Location: $errorurl” );
    exit ;
    }
    if ( preg_match( “/[rn]/”, $fullname ) || preg_match( “/[rn]/”, $email ) ) {
    header( “Location: $errorurl” );
    exit ;
    }
    if (strlen( $my_recaptcha_private_key )) {
    require_once( ‘recaptchalib.php’ );
    $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER, $_POST, $_POST );
    if (!$resp->is_valid) {
    header( “Location: $errorurl” );
    exit ;
    }
    }
    if (empty($email)) {
    $email = $mailto ;
    }
    $fromemail = $use_webmaster_email_for_from ? $mailto : $email ;

    if (function_exists( ‘get_magic_quotes_gpc’ ) && get_magic_quotes_gpc()) {
    $comments = stripslashes( $comments );
    }

    $messageproper =
    “This message was sent from:” . $content_nl .
    “$http_referrer” . $content_nl .


    ” . $content_nl .
    “Name of sender: $fullname” . $content_nl .
    “Email of sender: $email” . $content_nl .


    COMMENTS


    ” . $content_nl . $content_nl .
    wordwrap( $comments, MAX_LINE_LENGTH, $content_nl, true ) . $content_nl . $content_nl .


    ” . $content_nl ;

    $headers =
    “From: “$fullname” <$fromemail>” . $headersep . “Reply-To: “$fullname” <$email>” . $headersep . “X-Mailer: chfeedback.php 2.16.2” .
    $headersep . ‘MIME-Version: 1.0’ . $headersep . $content_type ;

    if ($use_envsender) {
    mail($mailto, $subject, $messageproper, $headers, $envsender );
    }
    else {
    mail($mailto, $subject, $messageproper, $headers );
    }
    header( “Location: $thankyouurl” );
    exit ;

    ?>

    #129794

    my friend give me this PHP code

    #129796

    here is the code. please check

    http://codepen.io/anon/pen/pqfnI

    #129822
    JohnMotylJr
    Participant

    @adnan4ali, first off you have two links to jQuery in your head. Second, i would move all scripts to the bottom of your body. Third i would suggest using ajax to process the form. Fourth, incorporate client side validation. Fifth, add ID’s to your form inputs!?

    Im not super strong in php but the basics would be to collect the post data, validate it, and mail it.

    If it was me?

    html

    <form id="form">
    <fieldset>
    <input type="text" name="name" placeholder="Name" id="js-name">
    <input type="email" name="email" placeholder="Email" id="js-email">
    <input type="number" name="phone" placeholder="Phone" id="js-phone">
    <textarea name="message" placeholder="Message" id="js-message"></textarea>
    <button type="reset" id="js-reset">Clear</button>
    <button type="submit" id="js-submit">Send</button>
    </fieldset>
    </form>

    <script src="js/jquery-1.7.2.min.js"></script>
    <script>

    </script>

    javascript

    $('#js-submit').on('click', function(e) {
    e.preventDefault();
    $.ajax({
    type: 'POST',
    url: 'path/to/submit.php',
    data: {
    name: $.trim($('#description').val()),
    email: $.trim($('#resource').val()),
    phone: $.trim($('#language').val()),
    message: $.trim($('#title').val())
    }
    }).error(function (jqXHR, textStatus) {
    // errors
    }).success(function (data) {
    // success from the server
    }).complete(function (data) {
    // completed
    });
    });

    php

    <?php
    $name = $_POST; // Collects post data for name
    $email = $_POST; // " email
    $phone = $_POST; // " phone
    $message = $_POST; // " message

    # Do all your validation here as well as client side

    # Use the mail( ) function **if your server supports it, which it should**
    ?>

    Always make sure you do client side validation as well as server side.

    #129997

    all information is helpful for me and my friend. thanks i am working on it

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Back End’ is closed to new topics and replies.