Visualizzazione dei risultati da 1 a 4 su 4

Discussione: form mail

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    2

    form mail

    Salve a tutti! mi presento, mi chiamo andrea!
    Sono alle prese con il mio primo form per inviare mail, mi sta dando del filo da torcere..
    Premetto che ho cercato e letto i vari casi postati dagli altri utenti sul forum, ma non son riuscito a risolvere il mio problema..
    Ecco il codice html:
    codice:
    <form action="contact.php" id="contact-form" method="post" />
    	<fieldset>
    		<input type="hidden" name="serverProcessorType" id="serverProcessorType" value="php" />
    		<input type="hidden" name="smtpMailServer" id="smtpMailServer" value="localhost" />
    		<input type="hidden" name="stripHTML" id="stripHTML" value="true" />
    			                                    				
    		<div class="rowElem">
    			<input type="text" name="name" id="name" value="Name:" onfocus="if(this.value=='Name:'){this.value=''}" onblur="if(this.value==''){this.value='Name:'}" />
    			
    			
    		</div>
    		
    		<div class="rowElem">
    			<input type="email" name="email" id="email" value="E-mail:" onfocus="if(this.value=='E-mail:'){this.value=''}" onblur="if(this.value==''){this.value='E-mail:'}" />
    			
    			
    		</div>
    		
    		<div class="rowElem">
    			<input type="text" name="subject" id="subject" value="Subject:" onfocus="if(this.value=='Subject:'){this.value=''}" onblur="if(this.value==''){this.value='Subject:'}" />
    			
    			
    		</div>
    		
    		<div class="textarea-box">
    			<textarea onfocus="if(this.value=='Message:'){this.value=''}" onblur="if(this.value==''){this.value='Message:'}" name="message" id="message">Message:</textarea>
    			
    			
    		</div>
    		
    		<div class="alignright">
    		    
    			Reset<input type="submit" class="button" value="Invia">
    		</div>
    	</fieldset>
    </form>
    ho provato un sacco di tutorial per la pagina in php, che nonostante sembri la più semplice mi sta dando problemi..
    non riesco ad inviare la mail.
    potrebbe essere che ci sia qualche conflitto con un css?
    potete suggerirmi una buona soluzione?
    Grazie mille in anticipo!

  2. #2
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,781
    non mi pare che il form abbia problemi di sorta (a parte quello strano reset), e di certo il css è ininfluente

    controlla cosa spedisci al server: ovvero cosa ricevi su contact.php

  3. #3
    Originariamente inviato da Vincent.Zeno
    non mi pare che il form abbia problemi di sorta (a parte quello strano reset), e di certo il css è ininfluente

    controlla cosa spedisci al server: ovvero cosa ricevi su contact.php
    Già, il reset è deve esser così:

    codice:
    <input type="reset" value="Reset" class="button">
    Se posti il php vediamo..
    Social Network in costruzione.. Misto tra Twitter e Facebook.. Twitbook o facetter?

  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2011
    Messaggi
    2
    ora il php non ce l'ho, non so come dovrebbe essere perché non conosco la sua sintassi.. ne ho provati di vari, ma senza risultato.. avrei proprio bisogno di aiuto su questo punto.. se potete suggerirmi un tutorial.. thx

    edit: il file php che sto usando ora.. l'ultimo tentativo provato..
    ho modificato ora il campo email_to
    codice:
    <?php
    if(isset($_POST['email'])) {
         
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "miamail@hotmail.it";
        $email_subject = "prevent";
         
         
        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.
    
    ";
            echo $error."
    
    ";
            echo "Please go back and fix these errors.
    
    ";
            die();
        }
         
        // validation expected data exists
        if(!isset($_POST['first_name']) ||
            !isset($_POST['last_name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['telephone']) ||
            !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
        $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.
    ';
      }
        $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.
    ';
      }
      if(!preg_match($string_exp,$last_name)) {
        $error_message .= 'The Last Name you entered 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.\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);  
    ?>
     
    <?php
    }
    ?>

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.