Jump to content

tomaszko

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tomaszko's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, todays problem. I've database of clients, some of them are in groups. Sending msg to choosen clients works perfectly, but to specified group no. Oh and one more thing. For now it only sends to FIRST client in GROUP. Here is tables: client: id_client group_id name surname mail group: id_group name and PHP code: <table method='get'> <tr><th></th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=nazwa">Nazwa</a> </th></tr> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <?php while ($rekord = mysql_fetch_assoc($wynik)) { ?> <tr> <td><input type="checkbox" name="id[]" value="<?php echo $rekord['id_grupa']; ?>" /></td> <td><?php echo $rekord['nazwa'];?></td> </td> </tr> <?php } ?></table><br> <table method='get'> <tr> <th></th> <th> Tytuł</th><th>Treść</th></tr> <?php while ($rekord = mysql_fetch_assoc($szablon)) { ?> <tr> <td><input type="radio" name="cont[]" value="<?php echo $rekord['id_szablon']; ?>"/></td> <td><?php echo $rekord['tytul'];?></td> <td><?php echo $rekord['tresc'];?></td> </tr> <?php } ?> </table> <?php if(isset($_POST['klik'])) { if(isset($_POST['id'])){ $mail=''; $nazwisko=''; $imie=''; $allEmails = array(); // This will hold ALL email addresses you want to send to foreach($_POST['id'] as $idi){ $sql="SELECT imie,nazwisko,mail FROM klient, grupa WHERE klient.grupa_id = ".$idi; //$sql="SELECT imie,nazwisko,mail FROM klient, grupa WHERE id_klient=".$idi; $res=mysql_query($sql); $dane_klienta=mysql_fetch_array($res); $imie=$imie.''.$dane_klienta[0]; $nazwisko=$nazwisko.''.$dane_klienta[1]; $mail=$dane_klienta[2]; $allEmails[] = $mail; // add this address } if(isset($_POST['cont'])){ $tytul=''; $tresc=''; foreach($_POST['cont'] as $conti){ $zap="SELECT tytul,tresc FROM szablon WHERE id_szablon=".$conti; $w=mysql_query($zap); $cont_szablon=mysql_fetch_array($w); $tytul=$tytul.''.$cont_szablon[0]; $tresc=$tresc.''.$cont_szablon[1]; } require_once($_SERVER['DOCUMENT_ROOT'].'/lib/phpmailer/class.phpmailer.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/lib/phpmailer/class.smtp.php'); $wiad = new PHPMailer(); // Instantiate your new class $wiad->IsSMTP(); // set mailer to use SMTP $wiad->SMTPAuth = true; // turn on SMTP authentication $wiad->Host = "smtp.gmail.com"; // specify main and backup server $wiad->SMTPSecure= 'ssl'; // Used instead of TLS when only POP mail is selected $wiad->Port = 465; // Used instead of 587 when only POP mail is selected $wiad->Username = "[email protected]"; $wiad->Password = "jelcar1234"; $wiad->From = "[email protected]"; //Aparently must be the same as the UserName $wiad->FromName = "JelCar"; $wiad->CharSet = "UTF-8"; foreach ($allEmails as $mail) { $wiad->AddAddress ($mail); } $wiad->Body = ($tytul); $wiad->AltBody = "Wiadomosc txt"; $wiad->Subject = ($tresc); if(!$wiad->Send()) { echo "There was an error sending the message:" . $wiad->ErrorInfo; exit; } else { // $zapytanie = "INSERT INTO klient_mail,mail (id_klient, id_mail), (tytul, tresc) VALUES ('$idi','$conti'), ('$tytul', '$tresc')"; // $wstaw = mysql_query($zapytanie); $wiad->clearAddresses(); echo "Wysłano"; } }else{echo 'Wybierz odbiorców/szablon.'; }}} ?> <input type="submit" name="klik" value="Wyslij" onClick='fireMyPopup()'> <br/></form>
  2. Hello, today's problem - my table only shows recipent which are in group, not ones without a group. I think I made wrong query to database. $q = "SELECT * FROM recipent, group WHERE group.id_group=recipent.group_id"; $w = mysql_query($q) or die ('Error: '. mysql_error()); ?> <hr /> <table method='get'> <tr><th></th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=imie">Imię</a> </th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=nazwisko">Nazwisko</a> </th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=telefon">Telefon</a></th><th><a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=mail">Mail</a> </th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=miasto">Miasto</a></th><th><a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=ulica">Ulica</a> </th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=kodpocztowy">Kod Pocztowy</a></th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=grupa_id">Grupa</a></th></tr> <?php while ($record = mysql_fetch_assoc($w)) { ?> <tr> <td><input type="checkbox"/></td> <td><?php echo $rekord['imie'];?></td> <td><?php echo $rekord['nazwisko'];?></td> <td><?php echo $rekord['telefon']; ?></td> <td><?php echo $rekord['mail'];?></td> <td><?php echo $rekord['miasto'];?></td> <td><?php echo $rekord['ulica']; ?></td> <td><?php echo $rekord['kodpocztowy']; ?></td> <td><?php echo $rekord['nazwa']; ?></td> <td><a href="odbiorcy_edytuj.php?akcja=edytuj&id_klient=<?php echo $rekord['id_klient'];?>"><?php echo "Edytuj"?></a></td> <td><a href="odbiorcy_usun.php?akcja=usun&id_klient=<?php echo $rekord['id_klient'];?>"><?php echo "Usuń"?></a></td> </td> </tr> <?php } ?> </table> And code bellow is cell where group name is displayed. <td><?php echo $rekord['nazwa']; ?></td>
  3. Hello , i've got a little problem. I'm checking list of recipents by checkboxes. Then it should send mail to everyony of selected recipents. But it only works with ONE recipent. I know that part: $wiad->AddAddress ($mail) needs to be looped, but i can't manage to do that <?php include ('conf.php'); ?> <?php if(isset($_GET["sortuj"])) $sortuj = $_GET["sortuj"]; else $sortuj = "id_klient"; // wygeneruj tabelê ze wszystkimi produktami $zapytanie = "SELECT * FROM klient ORDER BY $sortuj "; //$zapytanie = "SELECT * FROM produkty ORDER BY nazwa" ; $wynik = mysql_query($zapytanie) or die ('B³±d: '. mysql_error()); $zapytanie2 = "SELECT * FROM szablon"; //$zapytanie = "SELECT * FROM produkty ORDER BY nazwa" ; $szablon = mysql_query($zapytanie2) or die ('Błąd: '. mysql_error()); ?> <table method='get'> <tr><th></th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=imie">Imię</a> </th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=nazwisko">Nazwisko</a> </th><th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=telefon">Telefon</a></th><th><a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=mail">Mail</a> </th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=miasto">Miasto</a></th><th><a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=ulica">Ulica</a> </th> <th> <a href="<?php echo $_SERVER['PHP_SELF'];?>?sortuj=kodpocztowy">Kod Pocztowy</a></th><th><a href="#" id="expander">Zwiń</a></th></tr> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <?php while ($rekord = mysql_fetch_assoc($wynik)) { ?> <tr> <td><input type="checkbox" name="id[]" value="<?php echo $rekord['id_klient']; ?>" /></td> <td><?php echo $rekord['imie'];?></td> <td><?php echo $rekord['nazwisko'];?></td> <td><?php echo $rekord['telefon']; ?></td> <td><?php echo $rekord['mail']?></td> <td><?php echo $rekord['miasto'];?></td> <td><?php echo $rekord['ulica']; ?></td> <td><?php echo $rekord['kodpocztowy']; ?></td> </td> </tr> <?php } ?></table><br> <table method='get'> <tr> <th></th> <th> Tytuł</th><th>Treść</th></tr> <?php while ($rekord = mysql_fetch_assoc($szablon)) { ?> <tr> <td><input type="radio" name="cont[]" value="<?php echo $rekord['id_szablon']; ?>"/></td> <td><?php echo $rekord['tytul'];?></td> <td><?php echo $rekord['tresc'];?></td> </tr> <?php } ?> </table> <?php if(isset($_POST['klik'])) { if(isset($_POST['id'])){ $mail=''; $nazwisko=''; $imie=''; foreach($_POST['id'] as $idi){ $sql="SELECT imie,nazwisko,mail FROM klient WHERE id_klient=".$idi; $res=mysql_query($sql); $dane_klienta=mysql_fetch_array($res); $imie=$imie.''.$dane_klienta[0]; $nazwisko=$nazwisko.''.$dane_klienta[1]; $mail=$mail.''.$dane_klienta[2]; } if(isset($_POST['cont'])){ $tytul=''; $tresc=''; foreach($_POST['cont'] as $conti){ $zap="SELECT tytul,tresc FROM szablon WHERE id_szablon=".$conti; $w=mysql_query($zap); $cont_szablon=mysql_fetch_array($w); $tytul=$tytul.''.$cont_szablon[0]; $tresc=$tresc.''.$cont_szablon[1]; } require_once($_SERVER['DOCUMENT_ROOT'].'/lib/phpmailer/class.phpmailer.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/lib/phpmailer/class.smtp.php'); $wiad = new PHPMailer(); // Instantiate your new class $wiad->IsSMTP(); // set mailer to use SMTP $wiad->SMTPAuth = true; // turn on SMTP authentication $wiad->Host = "smtp.gmail.com"; // specify main and backup server $wiad->SMTPSecure= 'ssl'; // Used instead of TLS when only POP mail is selected $wiad->Port = 465; // Used instead of 587 when only POP mail is selected $wiad->Username = "xxx"; $wiad->Password = "xxx"; $wiad->From = "xxx"; //Aparently must be the same as the UserName $wiad->FromName = "xxx"; $wiad->CharSet = "UTF-8"; $wiad->AddAddress ($mail); $wiad->Body = ($tytul); $wiad->AltBody = "Wiadomosc txt"; $wiad->Subject = ($tresc); if(!$wiad->Send()) { echo "There was an error sending the message:" . $wiad->ErrorInfo; exit; } else { $wiad->clearAddresses(); echo "Wysłano"; } }else{echo 'Wybierz odbiorców/szablon.'; }}} ?> <input type="submit" name="klik" value="Wyslij" onClick='fireMyPopup()'> <br/></form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.