Visualizzazione dei risultati da 1 a 2 su 2

Discussione: contact form elements

  1. #1
    Utente di HTML.it L'avatar di sberm
    Registrato dal
    Nov 2005
    Messaggi
    150

    contact form elements

    Ciaoo,
    ho il seguente script inserito in una pagina php per un contact form funzionante.


    <?php
    Boom. There it is.
    */

    // Who you want to recieve the emails from the form. (Hint: generally you.)
    $sendto = 'paolomontrucchio@gmail.com';

    // The subject you'll see in your inbox
    $subject = 'Contact from contact form';

    // Message for the user when he/she doesn't fill in the form correctly.
    $errormessage = 'Oops! There seems to have been a problem. May we suggest...';

    // Message for the user when he/she fills in the form correctly.
    $thanks = "Thanks for the email! We'll get back to you as soon as possible!";

    // Message for the bot when it fills in in at all.
    $honeypot = "You filled in the honeypot! If you're human, try again!";

    // Various messages displayed when the fields are empty.
    $emptyname = 'Entering your name?';
    $emptyemail = 'Entering your email address?';
    $emptytele = 'Entering your telephone number?';
    $emptymessage = 'Entering a message?';

    // Various messages displayed when the fields are incorrectly formatted.
    $alertname = 'Entering your name using only the standard alphabet?';
    $alertemail = 'Entering your email in this format: name@example.com?';
    $alerttele = 'Entering your telephone number in this format: 555-555-5555?';
    $alertmessage = "Making sure you aren't using any parenthesis or other escaping characters in the message? Most URLS are fine though!";

    // --------------------------- Thats it! don't mess with below unless you are really smart! ---------------------------------

    //Setting used variables.
    $alert = '';
    $pass = 0;

    // Sanitizing the data, kind of done via error messages first. Twice is better!
    function clean_var($variable) {
    $variable = strip_tags(stripslashes(trim(rtrim($variable))));
    return $variable;
    }

    //The first if for honeypot.
    if ( empty($_REQUEST['last']) ) {

    // A bunch of if's for all the fields and the error messages.
    if ( empty($_REQUEST['name']) ) {
    $pass = 1;
    $alert .= "[*]" . $emptyname . "";
    } elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['name'] ) ) {
    $pass = 1;
    $alert .= "[*]" . $alertname . "";
    }
    if ( empty($_REQUEST['email']) ) {
    $pass = 1;
    $alert .= "[*]" . $emptyemail . "";
    } elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_REQUEST['email']) ) {
    $pass = 1;
    $alert .= "[*]" . $alertemail . "";
    }
    if ( empty($_REQUEST['tele']) ) {
    $pass = 1;
    $alert .= "[*]" . $emptytele . "";
    } elseif ( !ereg( "\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}", $_REQUEST['tele'] ) ) {
    $pass = 1;
    $alert .= "[*]" . $alerttele . "";
    }
    if ( empty($_REQUEST['message']) ) {
    $pass = 1;
    $alert .= "[*]" . $emptymessage . "";
    } elseif ( ereg( "[][{}()*+?\\^$|]", $_REQUEST['message'] ) ) {
    $pass = 1;
    $alert .= "[*]" . $alertmessage . "";
    }

    //If the user err'd, print the error messages.
    if ( $pass==1 ) {

    //This first line is for ajax/javascript, comment it or delete it if this isn't your cup o' tea.
    echo "<script>$(\".message\").hide(\"slow\").show(\"slo w\"); </script>";
    echo "" . $errormessage . "";
    echo "<ul>";
    echo $alert;
    echo "[/list]";

    // If the user didn't err and there is in fact a message, time to email it.
    } elseif (isset($_REQUEST['message'])) {

    //Construct the message.
    $message = "From: " . clean_var($_REQUEST['name']) . "\n";
    $message .= "Email: " . clean_var($_REQUEST['email']) . "\n";
    $message .= "Telephone: " . clean_var($_REQUEST['tele']) . "\n";
    $message .= "Message: \n" . clean_var($_REQUEST['message']);
    $header = 'From:'. clean_var($_REQUEST['email']);

    //Mail the message - for production
    mail($sendto, $subject, $message, $header);
    //This is for javascript,
    echo "<script>$(\".message\").hide(\"slow\").show(\"slo w\").animate({opacity: 1.0}, 4000).hide(\"slow\"); $(':input').clearForm() </script>";
    echo $thanks;

    die();

    //Echo the email message - for development
    //echo "

    " . $message;

    }

    //If honeypot is filled, trigger the message that bot likely won't see.
    } else {
    echo "<script>$(\".message\").hide(\"slow\").show(\"slo w\"); </script>";
    echo $honeypot;
    }
    ?>

    Vorrei personalizzare gli input.
    Ora presenti ci sono:
    - Name
    - Email
    - Telephone
    - Message


    Vorrei tenere solamente:
    - Name
    - Email


    Se tolgo le REQUEST relative a Telephone e Message non funziona più.
    Quali sono le parti da cancellare?
    grazie

  2. #2
    Utente di HTML.it L'avatar di sberm
    Registrato dal
    Nov 2005
    Messaggi
    150
    ce l'ho fatta da solo...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.