Pagina 2 di 3 primaprima 1 2 3 ultimoultimo
Visualizzazione dei risultati da 11 a 20 su 23
  1. #11
    Codice PHP:

    function showAnswers2($answers,$questions,$sendemail) {_


        
    for($x 0$xcount($answers); $x++) {
            if (
    $x == 0) {_
                 $output 
    "<div class=\"qanda clear\">\n";
            } else {
    _
                $output 
    "<div class=\"qanda\">";
    _         }
    _    $output .= '<h4>Domanda' . ($x+1) . ': ' $questions[$x] . '</h4>';_
        $output 
    .= "[list=1]\n";
    _    for ($y 0;$ycount($answers[$x]); $y++) {
    _        if (($answers[$x][$y] === $answers[$x][0]) && (in_array($answers[$x][$y],$_SESSION['correct']))) {
    _            $output .= "<li class=\"correctuser\">{$answers[$x][$y]} (Corretta!)\n";
    _        } else if ($answers[$x][$y] === $answers[$x][0]) {
    _            $output .= "<li class=\"correct\">{$answers[$x][$y]}\n";
    _        } else if (in_array($answers[$x][$y],$_SESSION['wrong'])) {
    _            $output .= "<li class=\"wrong\">{$answers[$x][$y]} (Erratta!)\n";
    _        } else {_
    _            $output 
    .= "[*]{$answers[$x][$y]}\n";
            }
        }
        
    $output .= "[/list]</div>\n";
        
    //echo $output;
        
    }
        
        
    //Invio email dei risultati
    $to $sendemail;
    $subject "Risultato quiz di $_SESSION[user]";
    $message "Nome: $_SESSION[user],
     "
    ;
    $message .= "Codice Verifica: $_SESSION[codverifica] 
    "
    ;
    $message .= "Risultati:".$output.
    "
    ;
    $headers "From: $_SESSION[email]""\r\n";
    $headers .= 'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    mail($to,$subject,$message,$headers);_

        
        
        
        
    }//Chiusura funzione 
    Si usa cosi showAnswers2('primoparm','secondoparm','emailricev ente')

  2. #12
    La variabile output cosi mi restituisce sempre l'ultimo valore del ciclo e non mi stampa nella mail tutto il ciclo come da funzione.

    Io devo stampare nella mail tutto il ciclo, ho provato anche ad inserire la funzione stessa nella mail ma nulla oppure l'ho inserita in modo sbagliato non so.

  3. #13
    Ho provato anche inserendo la funzione all'interno della funzione che si occupa di inviare la mail, ricevo la mail ma con la parte Risultati vuota.

    codice:
    function showAnswers($answers,$questions) { 
    	for($x = 0; $x< count($answers); $x++) {
    		if ($x % 2 == 0) { 
    		 	$output = "<div class=\"qanda clear\">\n";
    		} else { 
    			$output = "<div class=\"qanda\">";
      		}
     	$output .= '<h4>Domanda' . ($x+1) . ': ' . $questions[$x] . '</h4>'; 
    	$output .= "
    1. \n"; for ($y = 0;$y< count($answers[$x]); $y++) { if (($answers[$x][$y] === $answers[$x][0]) && (in_array($answers[$x][$y],$_SESSION['correct']))) { $output .= "<li class=\"correctuser\">{$answers[$x][$y]} (Corretta!)\n"; } else if ($answers[$x][$y] === $answers[$x][0]) { $output .= "<li class=\"correct\">{$answers[$x][$y]}\n"; } else if (in_array($answers[$x][$y],$_SESSION['wrong'])) { $output .= "<li class=\"wrong\">{$answers[$x][$y]} (Erratta!)\n"; } else { $output .= "
    2. {$answers[$x][$y]}\n"; } } $output .= "
    </div>\n"; echo $output; } } function sendemail() { //Invio email dei risultati $to = "feder.sanna@gmail.com"; $subject = "Risultato quiz di $_SESSION[user]"; $message = "Nome: $_SESSION[user], "; $message .= "Codice Verifica: $_SESSION[codverifica] "; $message .= "Risultati: ".showAnswers($answers,$questions); $headers = "From: $_SESSION[email]". "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$message,$headers); }

  4. #14
    Ma per logica se inserisco la funzione nell'invio della mail dovrebbe funzionare, come mai non restituisce nessun valore? Mi sembra impossibile non riuscire a recuperare il ciclo e utilizzarlo all'interno della mail.


    codice:
    
    function sendemail() {
    	
    	
    		//Invio email dei risultati
    	$to = "feder.sanna@gmail.com";
    	$subject = "Risultato quiz di $_SESSION[user]";
    	$message = "Nome: $_SESSION[user],
     ";
    	$message .= "Codice Verifica: $_SESSION[codverifica] 
    ";
    	$message .= "Risultati: 
    ".showAnswers($answers,$questions);
    	$headers = "From: $_SESSION[email]". "\r\n";
    	$headers .= 'MIME-Version: 1.0' . "\r\n";
    	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    	mail($to,$subject,$message,$headers); 
    		
    	
    	
    	
    	}

  5. #15
    Se l'output della prima funzione te lo visualizza con l'echo prova a creare una funzione sendmail che abbia come parametro il contenuto del messaggio dell'email e il destinatario e nella funzione showanswers al posto dell'echo richiama la funzione send mail con la variabile $output

    Sendmail($output,$destinatario)

    Ce xD è impossibile che avrai il messaggio vuoto (sempre $output assuma un valore nella funzione)

  6. #16
    Ti ringrazio infinitamente per l'aiuto che mi stai dando, ma non ho capito esattamente cosa dovrei provare a fare....

    Il dilemma è che essendo un ciclo io devo (penso per logica) utilizzare l'intero ciclo, perché altrimenti se prendo il valore della variabile $outiput mi restituisce (ovviamente) solo l'ultimo valore del ciclo e non tutto il ciclo come invece servirebbe a me. E proprio qui che mi perdo purtroppo non riesco a mettere il ciclo all'interno della funzione di invio mail.

    Ho pensato anche di fare diversamente, provo ad inserire tutto quando all'interno di un file di testo, con le prove che ho effettuato il file di testo viene creato ma vuoto.

  7. #17
    Ho capito il tuo problema prova così
    Ps ho modificato con ipad vedi eventuali errori
    Codice PHP:


    function showAnswers2($answers,$questions) { 
    $Recupero="";
        for(
    $x 0$xcount($answers); $x++) {
            if (
    $x == 0) { 
                 
    $output "<div class=\"qanda clear\">\n";
            } else { 
                
    $output "<div class=\"qanda\">";
              }
         
    $output .= '<h4>Domanda' . ($x+1) . ': ' $questions[$x] . '</h4>'
        
    $output .= "[list=1]\n";
         for (
    $y 0;$ycount($answers[$x]); $y++) {
             if ((
    $answers[$x][$y] === $answers[$x][0]) && (in_array($answers[$x][$y],$_SESSION['correct']))) {
                 
    $output .= "<li class=\"correctuser\">{$answers[$x][$y]} (Corretta!)\n";
             } else if (
    $answers[$x][$y] === $answers[$x][0]) {
                 
    $output .= "<li class=\"correct\">{$answers[$x][$y]}\n";
             } else if (
    in_array($answers[$x][$y],$_SESSION['wrong'])) {
                 
    $output .= "<li class=\"wrong\">{$answers[$x][$y]} (Erratta!)\n";
             } else { 
                 
    $output .= "[*]{$answers[$x][$y]}\n";
            }
        }
        
    $output .= "[/list]</div>\n";
             
    $Recupero $Recupero $output;
        }
    SendMail('email@live.it',$Recupero);
    }
    //Chiusura funzione

    //Funzione SendMail 
    Function SendMail($sendemail,$output){
    //Invio email dei risultati
    $to $sendemail;
    $subject "Risultato quiz di $_SESSION[user]";
    $message "Nome: $_SESSION[user],
     "
    ;
    $message .= "Codice Verifica: $_SESSION[codverifica] 
    "
    ;
    $message .= "Risultati:".$output.
    "
    ;
    $headers "From: $_SESSION[email]""\r\n";
    $headers .= 'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    mail($to,$subject,$message,$headers);


  8. #18
    Cosi non ricevo la mail!!

  9. #19
    Questa la modifichi 'email@live.it'?

  10. #20
    Ottimo problema risolto, un piccolo errore che non vedevo cosi ho risolto.

    Però ora vorrei capire perché cosi funziona, ti sarei immensamente grato se potessi darmi la spiegazione, perché chiamando la funzione sendemail con i parametri all'interno della funzione showanswers funziona tutto.

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