[PHP] Check Box_Privacy

lugalzaggesi

Nuovo Utente
1 Apr 2014
5
0
1
Siccome sono un asino vi chiedo umilmente aiuto per risolvere questo inghippo!
grazie! Devo solo inserire un checkbox privacy... Ma credo ci sia un errore nel codice php

Codice:
       <form name="contactform" method="post" action="send_form_email.php">
<table>
<tr>
<td>
<strong>Nome*</strong>
</td>
<td>
    <input type="first_name" name="first_name"size="20" maxlength="50" >
    </td>
    </tr>
    <tr>
    <td>
<strong>Cognome*</strong>
</td>
    <td>
    <input type="last_name" name="last_name" size="20" maxlength="50">
    </td>
    </tr>
    <tr>
    <td>
<strong>E-Mail*</strong>
</td>
<td>
    <input type="email" name="email" size="20" maxlength="50">
    </td>
    </tr>
    <tr>
    <td>
<strong>Telefono*</strong>
</td>
    <td>
    <input type="telephone" name="telephone" size="20" maxlength="50">
    </td>
    </tr>
    <tr>
    <td>
    
<strong>Messaggio*</strong>
</td>
    <td>
     <textarea name="comments" cols="20" rows="15"></textarea>
     </td>
     </tr>
    <tr>
    <td>
    
    
    <td> <input type="checkbox" name="privacy" value="privacy" class="required" />
<label for="Privacy Accettata" class="copy">
<a href="http://www.digitalrilievi.it/sito/privacy.php" target="nw" > Ho letto e accetto l'Informativa sulla Privacy </a>
</label>

</td>
     </tr>
    
 
  </td>
  <td>
<input type="submit" name="Submit" value="Invia il Messaggio">
  </td>
  </tr>
 
  </table>
  <p>
      
      <label></label>
      <label></label>
  <p class="Stile6 Stile9"><strong>Tutti i campi devono essere compilati </strong>
  <p>
    <label></label>
 
       </form> 
       <p>&nbsp;</p>
       <p>&nbsp;</p>
       <p>&nbsp;</p>
     </section>
  </div>





<?php

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

    

    // EDIT THE 2 LINES BELOW AS REQUIRED

    $email_to = "[email protected]";

    $email_subject = "Messaggio inviato dal sito web ";

    

    

    function died($error) {

        // your error code can go here

        echo "We are very sorry, but there were error(s) found with the form you submitted. ";

        echo "These errors appear below.<br /><br />";

        echo $error."<br /><br />";

        echo "Please go <a href='contatti.html'>back</a> and fix these errors.<br /><br />";

        die();

    }

    

    // validation expected data exists

    if(!isset($_POST['first_name']) ||

        !isset($_POST['last_name']) ||

        !isset($_POST['email']) ||

        !isset($_POST['telephone']) ||
        
        
!isset($_POST['privacy']) ||
        !isset($_POST['comments'])) {

        died('We are sorry, but there appears to be a problem with the form you submitted.');       

    }

    

    $first_name = $_POST['first_name']; // required

    $last_name = $_POST['last_name']; // required

    $email_from = $_POST['email']; // required

    $telephone = $_POST['telephone']; // not required

 $privacy = $_POST['privacy']; // not required

    $comments = $_POST['comments']; // required

    

    $error_message = "";

    $email_exp = '/^[A-Za-z0-9._%-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

  if(!preg_match($email_exp,$email_from)) {

    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';

  }

    $string_exp = "/^[A-Za-z .'-]+$/";

  if(!preg_match($string_exp,$first_name)) {

    $error_message .= 'The First Name you entered does not appear to be valid.<br />';

  }

  if(!preg_match($string_exp,$last_name)) {

    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';

  }

  if(strlen($comments) < 2) {

    $error_message .= 'The Comments you entered do not appear to be valid.<br />';

  }

  if(strlen($error_message) > 0) {

    died($error_message);

  }

    $email_message = "Form details below.\n\n";

    

    function clean_string($string) {

      $bad = array("content-type","bcc:","to:","cc:","href");

      return str_replace($bad,"",$string);

    }

    

    $email_message .= "First Name: ".clean_string($first_name)."\n";

    $email_message .= "Last Name: ".clean_string($last_name)."\n";

    $email_message .= "Email: ".clean_string($email_from)."\n";

    $email_message .= "Telephone: ".clean_string($telephone)."\n";

    $email_message .= "Comments: ".clean_string($comments)."\n";

    

    

// create email headers

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers); 

?>
 

Max 1

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
29 Feb 2012
4.312
334
83

Max 1

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
29 Feb 2012
4.312
334
83
Non disturbi! Ma bisogna tu abbi pazienza di attendere considerato che nessuno è obbligato a rispondere