Jump to content

MrVaux

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MrVaux's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I was really hoping some sort of help here. I googled the solution you provided but didn´t find anything of use. Below is the full script (send.php) with the latest modification. But it generates an error. Browser just comes out with "Failure" Im pretty sure this is the line that makes tho error. //Parents checkbox selected $ToEmail = "{$row->email}; {$row->mor_email}; {$row->far_email}"; mjdamato where are you Your knowledge is needed... <?php //Check if password is correct if($_POST['password'] != "yipiyaa") { //Password does not match echo "Password ikke udfyldt eller opgivet forkert !!!"; } elseif(!isset($_POST['mailtarget']) || count($_POST['mailtarget'])<1) { //No records were selected echo "Vælg venligst mindst én modtagergruppe"; } else { //Now that we know we are going to do a query we can connect to the DB include "config.php"; $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't establish connection"); mysql_select_db($dbname); //Clean the user input $gruppeArry = array_map('mysql_real_escape_string', $_POST['mailtarget']); $gruppeList = "'" . implode("', '", $gruppeArry) . "'"; //Create and run query $query = "SELECT email, mor_email, far_email, tilknytning, nyhedsbrev FROM medlemmer WHERE tilknytning IN ($gruppeList) && nyhedsbrev = 'Ja'"; $result = mysql_query($query) or die("Query:<br>$query<br>Error:<br>".mysql_error()); //Check if there were results if(mysql_num_rows($result)<1) { echo "Der blev ikke fundet nogen modtagere i den valgte gruppe"; } else { //Define these BEFORE the loop since they are static $EmailSubject = "Nyhedsbrev"; $mailheader = "From: BGA Fodbold <noreply@bga.dk>\r\n"; $mailheader .= "Reply-To: noreply@bga.dk\r\n"; $headers = "MIME-Version: 1.0\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY .= "<table width='738px' style='border-width:1px; border-style:solid; border-color:#999999;' cellspacing'0' cellpadding'0' bgcolor='#EEEEEE' align='center'>\n"; $MESSAGE_BODY .= " <tr>\n"; $MESSAGE_BODY .= " <td width='738px' align='center'><img src='http://www.bga.dk/medlemmer/newsletter/images/banner.jpg' border='1'></td>\n"; $MESSAGE_BODY .= " </tr>\n"; $MESSAGE_BODY .= " <tr>\n"; $MESSAGE_BODY .= " <td width='100%' align='left'><H2>BGA Nyhedsbrev</H2></td>\n"; $MESSAGE_BODY .= " </tr>\n"; $MESSAGE_BODY .= " <tr>\n"; $MESSAGE_BODY .= " <td>\n"; $MESSAGE_BODY .= "".nl2br($_POST["mailtekst"]).""; $MESSAGE_BODY .= " </td>\n"; $MESSAGE_BODY .= " </tr>\n"; $MESSAGE_BODY .= "</table>\n"; //Get recipient email address and send email $success = array(); $errors = array(); while ($row = mysql_fetch_object($result)) { //Parents checkbox NOT selected if(in_array('Foraldre', $_POST['mailtarget'])) { $ToEmail = $row->email; } else { //Parents checkbox selected $ToEmail = "{$row->email}; {$row->mor_email}; {$row->far_email}"; } $sent = mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); if($sent) { $success[] = $row->tilknytning; } else { $errors[] = $row->tilknytning; } } //Output success/error messages if(count($success)>0) { echo "Nyhedsbrevet udsendt til følgende grupper:<br>\n"; echo "<ul>\n"; foreach($success as $username) { echo "<li>{$username}</li>\n"; } echo "<ul>\n"; } if(count($errors)>0) { echo "Der opstod et problem med at sende ud til følgende gruppe:<br>\n"; echo "<ul>\n"; foreach($errors as $username) { echo "<li>{$username}</li>\n"; } echo "<ul>\n"; } echo "<br><br><a href='nyhedsbrev.html'>Udsend flere nyhedsbreve</a> - <a href='..\medlemmer.php'>Tilbage til medlemsliste</a>{$bga}"; } } ?>
  2. if(in_array('Foraldre', $_POST['mailtarget'])) { //Parents checkbox NOT selected $ToEmail = $row->email; } else { //Parents checkbox selected $ToEmail = "{$row->email}; {$row->mor_email}; {$row->far_email}"; } Ok, now i tried the above code but can´t really get it to work :'( I tried diffent things: The latest I only changed the: $ToEmail = $row->email; to $ToEmail = "{$row->email}; {$row->mor_email}; {$row->far_email}"; This meaning there is no check whatsoever if the parents checkbox is checked or not. If I understand this correctly, this should just send out mails to all parents in the choosen fields But I get an error page displaying nothing but "Failure" ? Are you sure of this?: $ToEmail = "{$row->email}; {$row->mor_email}; {$row->far_email}";
  3. I actually did try something like this, but when you are not sure of which symbol to use I get stuck ( or { or , I think this is going the right way but perhaps I didn´t explain myself enough. The checkboxes: (foraldre = parents) <input type="checkbox" name="mailtarget[]" value="BGA">BGA<br> <input type="checkbox" name="mailtarget[]" value="BGA spiller">BGA spillere<br> <input type="checkbox" name="mailtarget[]" value="BGA traner">BGA trænere<br> <input type="checkbox" name="mailtarget[]" value="GFK">GFK<br> <input type="checkbox" name="mailtarget[]" value="GFK spiller">GFK spillere<br> <input type="checkbox" name="mailtarget[]" value="GFK traner">GFK trænere<br> <input type="checkbox" name="mailtarget[]" value="AIF">AIF<br> <input type="checkbox" name="mailtarget[]" value="AIF spiller">AIF spillere<br> <input type="checkbox" name="mailtarget[]" value="AIF traner">AIF trænere<br> <input type="checkbox" name="mailtarget[]" value="Futsal">Futsal<br> <input type="checkbox" name="mailtarget[]" value="Andre">Andre<br> <input type="checkbox" name="mailtarget[]" value="Foraldre">Forældre<br><br> The MySQL table: -- -- Table structure for table `medlemmer` -- CREATE TABLE `medlemmer` ( `id` int(11) NOT NULL auto_increment, `fornavn` varchar(25) NOT NULL default '', `efternavn` varchar(50) NOT NULL default '', `adresse` varchar(50) NOT NULL default '', `postnr` varchar(25) NOT NULL default '', `bynavn` varchar(25) NOT NULL default '', `telefon` varchar(25) NOT NULL default '', `mobil` varchar(25) NOT NULL default '', `mor_mobil` varchar(25) NOT NULL default '', `far_mobil` varchar(25) NOT NULL default '', `email` varchar(50) NOT NULL default '', `mor_email` varchar(50) NOT NULL default '', `far_email` varchar(50) NOT NULL default '', `foedselsdato` varchar(25) NOT NULL default '', `aargang` varchar(25) NOT NULL default '', `hold` varchar(50) NOT NULL default '', `traeners_navn` varchar(25) NOT NULL default '', `aargangsleders_navn` varchar(50) NOT NULL default '', `tidligere_klubber` varchar(100) NOT NULL default '', `startet_til_fodbold` varchar(25) NOT NULL default '', `albertslund_medlem` varchar(25) NOT NULL default '', `glostrup_medlem` varchar(25) NOT NULL default '', `udvalgt_til_talenttrup` varchar(25) NOT NULL default '', `cheftraener` varchar(25) NOT NULL default '', `medlemsnr` varchar(25) NOT NULL default '', `tilknytning` varchar(50) NOT NULL default '', `indmeldt` varchar(25) NOT NULL default '', `udmeldt` varchar(25) NOT NULL default '', `billede` blob NOT NULL, `nyhedsbrev` varchar(25) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; As you can see there is no table for parents, but one called mor_email and one called far_email. So basicly I want to mail mum and dad too for the groups chosen when I select the foraldre (parents) checkbox. So if i want to mail the group BGA I want the parents to get the mail too when I also select the checkbox "foraldre" Does it make any sense at all?
  4. So I am back with this with a new struggle. The script is actually for sending out newsletters to all the members of a football club. The script below works fine for now. Added something here and there ex. the opportunity to unsubscribe to the newsletter. The table in the MySQL callled "medlemmer" is storing all the data including the members email and his moms and dads emails. 3 rows: email mom_email dad_email I want the script to send out emails to mom and dad to when the checkbox "parents" is checked but I have no idear how to do this. The query goes like this: $query = "SELECT email, tilknytning, nyhedsbrev FROM medlemmer WHERE tilknytning IN ($gruppeList) && nyhedsbrev = 'Ja'"; Do i have to add mom_email, dad_email to this. Already tried that with no luck. Any help would be appriciated. <?php //Check if password is correct if($_POST['password'] != "secret") { //Password does not match echo "Password ikke udfyldt eller opgivet forkert !!!"; } elseif(!isset($_POST['mailtarget']) || count($_POST['mailtarget'])<1) { //No records were selected echo "Vælg venligst mindst én modtagergruppe"; } else { //Now that we know we are going to do a query we can connect to the DB include "config.php"; $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't establish connection"); mysql_select_db($dbname); //Clean the user input $gruppeArry = array_map('mysql_real_escape_string', $_POST['mailtarget']); $gruppeList = "'" . implode("', '", $gruppeArry) . "'"; //Create and run query $query = "SELECT email, tilknytning, nyhedsbrev FROM medlemmer WHERE tilknytning IN ($gruppeList) && nyhedsbrev = 'Ja'"; $result = mysql_query($query) or die("Query:<br>$query<br>Error:<br>".mysql_error()); //Check if there were results if(mysql_num_rows($result)<1) { echo "Der blev ikke fundet nogen modtagere i den valgte gruppe"; } else { //Define these BEFORE the loop since they are static $EmailSubject = "BGA Nyhedsbrev"; $mailheader = "From: BGA\n"; $mailheader .= "Reply-To: noreply@bga.dk\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY .= "<table width='738px' style='border-width:1px; border-style:solid; border-color:#999999;' cellspacing'0' cellpadding'0' bgcolor='#EEEEEE' align='center'>\n"; $MESSAGE_BODY .= " <tr>\n"; $MESSAGE_BODY .= " <td width='738px' align='center'><img src='http://www.bga.dk/medlemmer/newsletter/images/banner.jpg' border='1'></td>\n"; $MESSAGE_BODY .= " </tr>\n"; $MESSAGE_BODY .= " <tr>\n"; $MESSAGE_BODY .= " <td width='100%' align='left'><H2>BGA Nyhedsbrev</H2></td>\n"; $MESSAGE_BODY .= " </tr>\n"; $MESSAGE_BODY .= " <tr>\n"; $MESSAGE_BODY .= " <td>\n"; $MESSAGE_BODY .= "".nl2br($_POST["mailtekst"]).""; $MESSAGE_BODY .= " </td>\n"; $MESSAGE_BODY .= " </tr>\n"; $MESSAGE_BODY .= "</table>\n"; //Get recipient email address and send email $success = array(); $errors = array(); while ($row = mysql_fetch_object($result)) { $ToEmail = $row->email; $sent = mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); if($sent) { $success[] = $row->tilknytning; } else { $errors[] = $row->tilknytning; } } //Output success/error messages if(count($success)>0) { echo "Nyhedsbrevet udsendt til følgende grupper:<br>\n"; echo "<ul>\n"; foreach($success as $username) { echo "<li>{$username}</li>\n"; } echo "<ul>\n"; } if(count($errors)>0) { echo "Der opstod et problem med at sende ud til følgende gruppe:<br>\n"; echo "<ul>\n"; foreach($errors as $username) { echo "<li>{$username}</li>\n"; } echo "<ul>\n"; } echo "<br><br><a href='nyhedsbrev.html'>Udsend flere nyhedsbreve</a> - <a href='..\medlemmer.php'>Tilbage til medlemsliste</a>{$bga}"; } } ?>
  5. mjdamato! You are my GOD Cleaned it for a few typing errors and it worked like a charm. Now I just need to take the time to study it so I can actually understand it. I really appreciate the time and effort you put into this, can´t really thank you enough.
  6. Still can´t get it to work I did the checkboxes but it only works when I only select one of the checkboxes? FORM: echo " <p>\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"BGA\" />BGA<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"BGA spiller\" />BGA spillere<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"BGA træner\" />BGA trænere<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"GFK\" />GFK<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"GFK spiller\" />GFK spillere<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"GFK træner\" />GFK trænere<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"AIF\" />AIF<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"AIF spiller\" />AIF spillere<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"AIF træner\" />AIF trænere<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"Futsal\" />Futsal<br />\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"Ledelse\" />Ledelse\n"; echo " <input type=\"checkbox\" name=\"mailtarget[]\" value=\"Andre\" />Andre\n"; echo " </p>\n"; SEND.PHP <?php include "config.php"; $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't establish connection"); mysql_select_db($dbname); $gruppe = $_REQUEST['mailtarget']; $N = count($gruppe); for($i=0; $i < $N; $i++) //$gruppe = $_REQUEST['bga']; // Running the MySQL query if($_REQUEST['password'] == "bgabga") { $results = mysql_query("SELECT * FROM medlemmer WHERE tilknytning = '$gruppe'"); //$results = mysql_query("SELECT * FROM medlemmer"); // Pulling up the results and iterating through them while ($row = mysql_fetch_object($results)) { // Emailing each member $ToEmail = $row->email; $EmailSubject = "BGA Nyhedsbrev"; $mailheader = "From: BGA\n"; $mailheader .= "Reply-To: noreply@bga.dk\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = " <H2>BGA Nyhedsbrev</H2><br>"; $MESSAGE_BODY .= "".nl2br($_POST["mailtekst"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); } mysql_query($query) or die("Nyhedsbrev udsendt med succes!<br><br><a href='mail.html'>Tilbage</a>"); } if ($query) { echo "Nyhedsbrev udsendt med succes!<br><br>"; echo "<a href='mail.html'>Tilbage</a>"; echo "$bga"; } else { echo "Password ikke udfyldt eller opgivet forkert !!!"; } ?> What am I missing here?
  7. Im petty new to php, so if you choose to help me please explain it like I was 5 What I am trying to do is this (short version) I have af form from which I can mail users from my DB. This form has a dropdown for which users I want to email. Lets say: All Group2+3 Group1 Group2 Group3 When hitting Submit you are taken to "send.php" As for now I have this: <?php include "config.php"; $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't establish connection"); mysql_select_db($dbname); $gruppe = $_REQUEST['gruppe']; // Running the MySQL query if($_REQUEST['password'] == "something") { $results = mysql_query("SELECT * FROM medlemmer WHERE tilknytning = '$gruppe'"); //$results = mysql_query("SELECT * FROM medlemmer"); // Pulling up the results and iterating through them while ($row = mysql_fetch_object($results)) { // Emailing each member $ToEmail = $row->email; $EmailSubject = "BGA Nyhedsbrev"; $mailheader = "From: BGA\n"; $mailheader .= "Reply-To: noreply@bga.dk\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = " <H2>BGA Nyhedsbrev</H2><br>"; $MESSAGE_BODY .= "".nl2br($_POST["mailtekst"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); } mysql_query($query) or die("Nyhedsbrev udsendt med succes!<br><br><a href='nyhedsbrev.php'>Tilbage</a>"); } if ($query) { echo "Nyhedsbrev udsendt med succes!<br><br>"; echo "<a href='nyhedsbrev.php'>Tilbage</a>"; } else { echo "Password ikke udfyldt eller opgivet forkert !!!"; } ?> This is ONLY woking for individual groups, when I want to email 2 or more groups I dont know what to do? I think I have to use arrays but I am not sure at all. Can someone help me here?
  8. What I want is basicly a newspaper function. I have a table like this: name hone website email name1 hone1 website1 email1 So what i want is creating a mail link that takes the 2 mailadresses from my table. 1 email with 2 reciepts. Just like you seperate them with the ; in you mailclient mailto:email; email1 Hoping someone can help, I think it is not that hard, I am just a nOOb
  9. Thanks a lot for taking your time to show me all this. I will try to recode it when i get off at work
  10. I am pretty n00B at php, so how where you to code what you suggest?
  11. Actually the </form> tag is to be cleaned up since there is no form on that page. Thanks for notice. What does this do? Does it write out the errors in the query? So it actually works at the moment, I think.... I changed the $news = $_GET['news']; to $news = $_REQUEST['news']; Thanks for all your input so far...
  12. I just decided to turn register globals from on to off. This change made a lot of trouble for me. I simply can´t update a record in the DB anymore. I get the following errormsg. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /customers/websides.dk/websides.dk/httpd.www/luffe/liga/admin/form_edit_news.php on line 18 I believe the problem is that the variable is empty, but Im not sure. How do I rewrite below to work with register globals = off <? include "admin_menu.php"; $id = $_GET['id']; $news = $_GET['news']; include "config.php"; $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't establish connection"); mysql_select_db($dbname); $query = "SELECT * FROM league_news WHERE id = id"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo "<H3>Info text</H3>\n"; echo "<table style='border-width:1px; border-style:dashed; border-color:#000000;' width='600px' cellpadding='4' cellspacing='0' bgcolor='#cee5cb'>\n"; echo "<tr>\n"; echo "<td width='100%'>$row[news]</td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<input type='hidden' name='id' value='{$_GET[id]}'>"; echo "<td width='100%'></td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<br>\n"; echo "</form>\n"; echo "<a href='form_edit_news.php?id=$row[id]'><b>Edit info</b></a>"; ?>
  13. WOW That did the trick. Had the team_1 and team_name switched around, but thats not your bad. Figured that out so it works like a charm... But I must admit.... I have no idea what your code is about??? Do you know why it is not possible the way i coded it?
  14. Really no one who knows what is wrong here
  15. Dear PHP Guru I have been strugling with a piece of code I can´t get to work, so I hope someone can help me out! It is a simple league system, and what I wan´t is this: Two teams play each other 5 times, the one team who wins 3 or more gets 2 points. So my problem is this. When I add the score for the two teams say Team 1 wins 3 times and Team 2 wins 2 times, the db with this data updates fine. But I would also like a piece of code that that adds 2 points to the winning team. I have tried to do so below, but it doesn.t seems to work. I get no data in the tabel where the 2 points should go in to? What is wrong here? <? include "config.php"; $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Couldn't establish connection"); mysql_select_db($dbname); if (isset($id)) { $query = "UPDATE league_matchresults SET result_1 = '$result_1', result_2 = '$result_2' WHERE id = $id"; @$result = mysql_query($query, $link); echo mysql_error(); if($result) { if ($result_1 >= 3) { $query = "UPDATE league_teamdata SET points = points + 2 WHERE team_1 = $team_name"; echo $team_1; // This is only to make sure I have the correct data in $team_1 - Seems to work! } } } ?>
×
×
  • 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.