Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Form di contatto

  1. #1

    Form di contatto

    Salve ragazzi, volevo un'informazione.
    Ho trovato un form di contatto in php, provandolo funziona tutto ok. Mi servirebbe però una cosa. In pratica vorrei che appena clicco su invia mi si apre un pop up di ringraziamento anzicchè una pagina bianca con la scritta. Stessa cosa per il messaggio che mi dice di inserire la mail o il nome ecc...

    il codice è questo:
    Codice PHP:
    <?php if (isset($_POST["op"]) && ($_POST["op"]=="send")) { /******** START OF CONFIG SECTION *******/   $sendto  "";   $subject "Website Contact Enquiry"// Select if you want to check form for standard spam text   $SpamCheck = "Y"; // Y or N   $SpamReplaceText = "*content removed*"; // Error message prited if spam form attack found $SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected. </font>
    [b]Your IP Number of [b]".getenv("REMOTE_ADDR")."[/bhas been logged.[/b]</p>"; /******** END OF CONFIG SECTION *******/   $name = $HTTP_POST_VARS['name'];   $email = $HTTP_POST_VARS['email'];   $message = $HTTP_POST_VARS['message'];   $headers = "From$email\n";   $headers . "MIME-Version1.0\n"                    . "Content-Transfer-Encoding7bit\n"                    . "Content-typetext/html;  charset = \"iso-8859-1\";\n\n"; if ($SpamCheck == "Y") { // Check for Website URL's in the form input boxes as if we block website URLs from the form, // then this will stop the spammers wastignt ime sending emails if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();} // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer   $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string   $name = preg_replace($pattern, "", $name);   $email = preg_replace($pattern, "", $email);   $message = preg_replace($pattern, "", $message); // Check for the injected headers from the spammer attempt // This will replace the injection attempt text with the string you have set in the above config section   $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");   $email = preg_replace($find, "$SpamReplaceText", $email);   $name = preg_replace($find, "$SpamReplaceText", $name);   $message = preg_replace($find, "$SpamReplaceText", $message); // Check to see if the fields contain any content we want to ban  if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}  if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}  // Do a check on the send email and subject text  if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}  if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} } // Build the email body text   $emailcontent = " -----------------------------------------------------------------------------    WEBSITE CONTACT ENQUIRY ----------------------------------------------------------------------------- Name: $name Email: $email Message: $message _______________________________________ End of Email "; // Check the email address enmtered matches the standard email address format  if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {   echo "

    It appears you entered an invalid email address</p>

    [
    url='javascript: history.go(-1)']Click here to go back[/url].</p>"; }  elseif (!trim($name)) {   echo "

    Please go back and enter a Name</p>

    [
    url='javascript: history.go(-1)']Click here to go back[/url].</p>"; }  elseif (!trim($message)) {   echo "

    Please go back and type a Message</p>

    [
    url='javascript: history.go(-1)']Click here to go back[/url].</p>"; }  elseif (!trim($email)) {   echo "

    Please go back and enter an Email</p>

    [
    url='javascript: history.go(-1)']Click here to go back[/url].</p>"; } // Sends out the email or will output the error message  elseif (mail($sendto$subject$emailcontent$headers)) {   echo "



    [b]Thank You $name[/b]</p>

    We will be in touch as soon as possible.</p>"; } } else { ?> <p align="center">Uno o piu campi vuoti</p> <?php } ?>
    Fatemi sapere grazie.

  2. #2
    Puoi formattare un pò il codice, altrimenti non posso aiutarti.
    Realizzazione Software, Siti Web ed E-commerce. Consulenza Software ed esperti open source ...
    Scopri i nostri servizi...

  3. #3
    In che senso? Di farlo tutto di seguito? Così come sotto?

    <?php
    if (isset($_POST["op"]) && ($_POST["op"]=="send")) {
    /******** START OF CONFIG SECTION *******/
    $sendto = "";
    $subject = "Website Contact Enquiry";
    // Select if you want to check form for standard spam text
    $SpamCheck = "Y"; // Y or N
    $SpamReplaceText = "*content removed*";
    // Error message prited if spam form attack found
    $SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.
    </font>
    Your IP Number of ".getenv("REMOTE_ADDR")." has been logged.</p>";
    /******** END OF CONFIG SECTION *******/
    $name = $HTTP_POST_VARS['name'];
    $email = $HTTP_POST_VARS['email'];
    $message = $HTTP_POST_VARS['message'];
    $headers = "From: $email\n";
    $headers . "MIME-Version: 1.0\n"
    . "Content-Transfer-Encoding: 7bit\n"
    . "Content-type: text/html; charset = \"iso-8859-1\";\n\n";
    if ($SpamCheck == "Y") {
    // Check for Website URL's in the form input boxes as if we block website URLs from the form,
    // then this will stop the spammers wastignt ime sending emails
    if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
    if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
    if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();}
    // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
    $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string
    $name = preg_replace($pattern, "", $name);
    $email = preg_replace($pattern, "", $email);
    $message = preg_replace($pattern, "", $message);
    // Check for the injected headers from the spammer attempt
    // This will replace the injection attempt text with the string you have set in the above config section
    $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
    $email = preg_replace($find, "$SpamReplaceText", $email);
    $name = preg_replace($find, "$SpamReplaceText", $name);
    $message = preg_replace($find, "$SpamReplaceText", $message);
    // Check to see if the fields contain any content we want to ban
    if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
    if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
    // Do a check on the send email and subject text
    if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
    if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
    }
    // Build the email body text
    $emailcontent = "
    -----------------------------------------------------------------------------
    WEBSITE CONTACT ENQUIRY
    -----------------------------------------------------------------------------
    Name: $name
    Email: $email
    Message: $message
    _______________________________________
    End of Email
    ";
    // Check the email address enmtered matches the standard email address format
    if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)) {
    echo "

    It appears you entered an invalid email address</p>

    Click here to go back.</p>";
    }
    elseif (!trim($name)) {
    echo "

    Please go back and enter a Name</p>

    Click here to go back.</p>";
    }
    elseif (!trim($message)) {
    echo "

    Please go back and type a Message</p>

    Click here to go back.</p>";
    }
    elseif (!trim($email)) {
    echo "

    Please go back and enter an Email</p>

    Click here to go back.</p>";
    }
    // Sends out the email or will output the error message
    elseif (mail($sendto, $subject, $emailcontent, $headers)) {
    echo "



    Thank You $name</p>

    We will be in touch as soon as possible.</p>";
    }
    }
    else {
    ?>
    <p align="center">Uno o piu campi vuoti</p>
    <?php } ?>

  4. #4
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    2,008
    secondo me la pop up e sconsigliata perche ormai i browser hanno il blocca popup ativato , comunque nel blocco dove spedisce la webmail puoi inserire una funzione javascript per aprire la popup



    // Sends out the email or will output the error message
    elseif (mail($sendto, $subject, $emailcontent, $headers)) {
    echo "



    Thank You $name</p>

    We will be in touch as soon as possible.</p>";

    //inserisci qui quello che vuoi che facia



    }
    }

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 © 2024 vBulletin Solutions, Inc. All rights reserved.