Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    6

    Aiuto con uno script di un FORM

    Salve a tutti,
    ho un problema con questo script per form invio mail
    In pratica vorrei impostarlo in modo che a seconda di ciò che gli utenti inseriscono nel campo $typeadv mi rimanda ad una pagina finale diversa..

    <?php

    if(isset($_POST['Email_Address'])) {

    include 'lite_settings.php';

    function died($error) {
    echo "Sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.

    ";
    echo $error."

    ";
    echo "Please go back and fix these errors.

    ";
    die();
    }

    if(!isset($_POST['Full_Name']) ||
    !isset($_POST['Email_Address']) ||
    !isset($_POST['Address']) ||
    !isset($_POST['Telephone_Number']) ||
    !isset($_POST['Your_Message'])) {
    died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $full_name = $_POST['Full_Name']; // required
    $email_from = $_POST['Email_Address']; // required
    $company = $_POST['Company']; // required
    $administrator = $_POST['Administrator']; // required
    $codicef = $_POST['Codicef']; // not required
    $category = $_POST['Category']; // required
    $address = $_POST['Address']; // required
    $telephone = $_POST['Telephone_Number']; // not required
    $typeadv = $_POST['Typeadv']; //not required
    $comments = $_POST['Your_Message']; // required

    $error_message = "";
    $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
    if(!eregi($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.
    ';
    }
    if(strlen($full_name) < 2) {
    $error_message .= 'Your Name does not appear to be valid.
    ';
    }
    if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.
    ';
    }

    if(strlen($error_message) > 0) {
    died($error_message);
    }
    $email_message = "Form details below.\r\n";

    function clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
    }

    $email_message .= "Full Name: ".clean_string($full_name)."\r\n";
    $email_message .= "Email: ".clean_string($email_from)."\r\n";
    $email_message .= "Company: ".clean_string($company)."\r\n";
    $email_message .= "Administrator: ".clean_string($administrator)."\r\n";
    $email_message .= "Codicef: ".clean_string($codicef)."\r\n";
    $email_message .= "Category: ".clean_string($category)."\r\n";
    $email_message .= "Address: ".clean_string($address)."\r\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\r\n";
    $email_message .= "Typeadv: ".clean_string($typeadv)."\r\n";
    $email_message .= "Message: ".clean_string($comments)."\r\n";

    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
    header("Location: $thankyou");
    ?>
    <script>location.replace('<?php echo $thankyou;?>')</script>
    <?
    }
    ?>

    E questo è lite_setting che mi imposta solo queste tre cose

    <?php

    $email_to = "mia@mail"; // your email address
    $email_subject = "Form Message"; // email subject line
    $thankyou = "silver.html"; // thank you page

    ?>


    Grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    6
    Nessuno mi può aiutare?

  3. #3
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    Codice PHP:
    switch ($typeadv)
    {
        case 
    1:
          
    header("Location: pagina1");
          break;
        case 
    2:
          
    header("Location: pagina2");
          break;
        default:
          
    header("Location: $thankyou");


  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    6
    Grazie!

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.