[PHP] Check Box_Privacy

lugalzaggesi

Nuovo Utente
1 Apr 2014
11
0
3
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._%-]+@[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.449
338
83
Non disturbi! Ma bisogna tu abbi pazienza di attendere considerato che nessuno è obbligato a rispondere
 
Discussioni simili
Autore Titolo Forum Risposte Data
Emix [PHP] Check - Select e recupero variabili PHP 40
E [PHP] Check tra 2 campi della stessa tabella PHP 14
F Cerco Hosting con VECCHIE versioni di php Hosting 0
Cosina Captcha php PHP 1
S passare un valore da un form a un file .php con metodo post PHP 4
N php msyql PHP 6
N php problemi a visualizzare video PHP 3
A menu a tendina php PHP 1
D protezione cartelle: blocco visualizzazione/scaricamento contenuto, ma abilitazione utilizzo dati da parte di file .php presenti sul sito Web Server 1
F Php date_diff PHP 1
K [PHP] Aggiungere caratteri ad una stringa in base alla lunghezza della stessa PHP 2
C Wp-admin a file php WordPress 5
Lino80 [Retribuito] Cerco programmatore php per modifica/inserimento funzione/valori da un plugin importer wordpress Offerte e Richieste di Lavoro e/o Collaborazione 0
csi Inviare file jpg in locale alla stampante con php PHP 0
M Passaggio variabili array php su un tasto jq PHP 3
E Php aggiornamento tabella PHP 9
G phpmailer e php 8.1 con estensione mysqli PHP 6
M Invio dati database via email php PHP 0
K [php] Problema con inner join PHP 4
K [php]form invio dati PHP 0
P Codifica caratteri speciali mysql php PHP 0
K [PHP] Problema con variabili concatenate. PHP 1
E Stampante termica escpos-php PHP 6
JeiMax Modifica codice php personalizzato PHP 2
G Come modificare un pdf in php PHP 1
U Link a doppio file PHP PHP 0
E PHP & jQuery PHP 8
N Passare array da php a javascript PHP 5
F Applicazione PHP/MySQL per prenotazioni: limitare il numero massimo di posti prenotabili PHP 20
L tipo boolean non funzionante su mariadb (mysql). E codice php 7.4. PHP 0
U PHP creare un file excel dopo ricerca nel DB PHP 0
M PHP/MySQL - Estrarre valori min e max di ogni gruppo PHP 5
F Php e fatturazione elettronica PHP 0
P lanciare script asp (o php) da jquery Javascript 1
Couting95 inserire dati da un file di testo in una tabella in php PHP 1
P Data scraping in PHP non funziona PHP 4
C Calcoli matematici in php PHP 5
F Scrivere dei dati in word con php PHP 0
D PHP leggere cartella di Windows PHP 1
I dominio aruba versione php server linux Domini 3
G Colorare menu select attraverso ricerca php PHP 0
L PHP motore di ricerca nel sito PHP 1
S PHP e Mysqli PHP 0
Y Stampare da php su un foglio A6 attraverso una stampante esterna PHP 1
M Visulizzare immagine con php PHP 8
G [PHP] Creare script di prenotazione con controllo disponibilità. PHP 7
G leggere file txt e stampare con php il contenuto a video PHP 7
F Ricreare struttura php+mysql su Xampp Apache 0
Z PHP.INI - STMP per invio email con PHP Server Dedicati e VPS 0
M Array associativi php su 2 campi mysql PHP 10

Discussioni simili