Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Invio email: prendere indirizzi da checkbox

    in home page ho questo:
    Codice PHP:
    <?php

    echo '<h2>Contatti</h2>';
    echo 
    '[url="email.php"]Invia mail[/url]

    '
    ;
    echo 
    '<form name="modulo">';
    echo 
    '<div id="demo">';
    echo 
    '<table id="example" class="display"><thead>';
    echo 
    '<th>[url="javascript:selectAll();"]Select All[/url]</th>';
    echo 
    '<th>NOME</th>';
    echo 
    '<th>COGNOME</th>';
    echo 
    '<th>EMAIL</th>';
    echo 
    '<th>SETTORE</th>';
    echo 
    '<th>STATO</th>';
    echo 
    '<th></th></thead>';
    echo 
    '<tfoot>';
    echo 
    '<th>[url="javascript:selectAll();"]Select All[/url]</th>';
    echo 
    '<th>NOME</th>';
    echo 
    '<th>COGNOME</th>';
    echo 
    '<th>EMAIL</th>';
    echo 
    '<th>SETTORE</th>';
    echo 
    '<th>ATTIVATO</th>';
    echo 
    '<th></th></tfoot>';
    foreach (
    showUtenti() as $row) {
        echo 
    '<tr><td><input type="checkbox" name="check" value="ON" /></td>';
        echo 
    '<td>' $row['utente_nome'] . '</td>';
        echo 
    '<td>' $row['utente_cognome'] . '</td>';
        echo 
    '<td>' $row['utente_email'] . '</td>';
        echo 
    '<td>' $row['settore'] . '</td>';
        if (
    $row['attivato'] == 0) {
            
    $stato 'NO';
        } else {
            
    $stato 'SI';
        }
        echo 
    '<td>' $stato '</td>';
        echo 
    '<td><a href="modifica.php?id=' $row['utente_id'] . '&n=' $row['utente_nome'] . '&c=' $row['utente_cognome'] . '&e=' $row['utente_email'] . '&s='
        
    $row['id_settore'] . '&a=' $row['attivato'] . '">Modifica</a> | ';
        echo 
    '[url="javascript:deleteConfirmation(' $row['utente_id'] . ')"]Elimina[/url]</td></tr>';
    }
    echo 
    '</table></div></form>';
    echo 
    '<div class="spacer"></div>

    '
    ;
    in pratica richiamo un metodo che esegue la query e costruisco una semplice table.
    c'è anche una colonna che contiene la checkbox e in alto c'è un link che mi indirizza a email.php che contiene un form.
    io vorrei passare a questo form tutti gli indirizzi email ceccati.
    come posso fare??

  2. #2
    ho messo il form nella stessa pagina e valorizzato le checkbox e sembra tutto funzionare:
    Codice PHP:
    <h2>Contatti</h2>
    <?php
    if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['send'])) {
        
    $check $_POST['check'];
        require_once 
    'lib/phpmailer.inc.php';
        
    $mail = new phpmailer();
        
    $mail->From 'ChiaraBaschieri.it';
        
    $mail->FromName "ChiaraBascheri.it";
        
    $mail->Subject $_POST['subject'];
        
    $mail->Body $_POST['messaggio'];
        foreach (
    $check as $send) {
            
    $mail->AddAddress($send);
        }
        
    $mail->Send();
        echo 
    'Mail inviata correttamente
    '
    ;
    }
    ?>
    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="send_email" onsubmit="return validaEmail();">
        <table>
            <tr>
                <td>Titolo:</td>
                <td><input type="text" name="nome" id="titolo" value="" /></td>
            </tr>
            <tr>
                <td>Subject:</td>
                <td><input type="text" name="subject" id="subject" value="" /></td>
            </tr>
            <tr>
                <td>Messaggio:</td>
                <td><textarea name="messaggio" rows="8" cols="30">
                    </textarea>
                </td>
            </tr>
            <tr>
                <td><input type="submit" value="Submit" name="send" /></td>
                <td></td>
            </tr>
        </table>
        


        <?php
        
    echo '<div id="demo">';
        echo 
    '<table id="example" class="display"><thead>';
        echo 
    '<th>[url="javascript:selectAll();"]Select All[/url]</th>';
        echo 
    '<th>NOME</th>';
        echo 
    '<th>COGNOME</th>';
        echo 
    '<th>EMAIL</th>';
        echo 
    '<th>SETTORE</th>';
        echo 
    '<th>STATO</th>';
        echo 
    '<th></th></thead>';
        echo 
    '<tfoot>';
        echo 
    '<th>[url="javascript:selectAll();"]Select All[/url]</th>';
        echo 
    '<th>NOME</th>';
        echo 
    '<th>COGNOME</th>';
        echo 
    '<th>EMAIL</th>';
        echo 
    '<th>SETTORE</th>';
        echo 
    '<th>ATTIVATO</th>';
        echo 
    '<th></th></tfoot>';
        foreach (
    showUtenti() as $row) {
            echo 
    '<tr><td><input type="checkbox" name="check[]" value="' $row['utente_email'] . '" /></td>';
            echo 
    '<td>' $row['utente_nome'] . '</td>';
            echo 
    '<td>' $row['utente_cognome'] . '</td>';
            echo 
    '<td>' $row['utente_email'] . '</td>';
            echo 
    '<td>' $row['settore'] . '</td>';
            if (
    $row['attivato'] == 0) {
                
    $stato 'NO';
            } else {
                
    $stato 'SI';
            }
            echo 
    '<td>' $stato '</td>';
            echo 
    '<td><a href="modifica.php?id=' $row['utente_id'] . '&n=' $row['utente_nome'] . '&c=' $row['utente_cognome'] . '&e=' $row['utente_email'] . '&s='
            
    $row['id_settore'] . '&a=' $row['attivato'] . '">Modifica</a> | ';
            echo 
    '[url="javascript:deleteConfirmation(' $row['utente_id'] . ')"]Elimina[/url]</td></tr>';
        }
        echo 
    '</table></div>';
        echo 
    '</form>';
        echo 
    '<div class="spacer"></div>

    '
    ;
    sicuramente si può fare meglio, ma più di cosi nn sono riuscito a fare.
    ciauz!

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.