
NICON
Members-
Posts
40 -
Joined
-
Last visited
Everything posted by NICON
-
Quite simple my mail is failing to send. The $_POST variable is not echo ing after being reassigned to $message and $email is not appearing either to satisfy the mail() function. I know i' <?php require_once __DIR__ . '/header.php'; require_once __DIR__ . '/includes/class_mtg_paginate.php'; $opts = ['grpgusers', 'gdemails']; $names = ['MS', 'GD']; $view = isset($_GET['view']) && in_array($_GET['view'], $opts) ? $_GET['view'] : 'grpgusers'; if (!$user_class->admin) $mtg->error("You don't have access"); if (array_key_exists('ms', $_POST)) { $db->query("SELECT id, email FROM grpgusers ORDER BY id ASC LIMIT 2"); $db->execute(); $rows = $db->fetch_row(); $success = 0; $failure = 0; echo 'Sending...<br />'; $message = stripslashes($_POST['message']); $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); foreach ($rows as $row) { $email = $row['email']; if (mail("$email", "A message from MS", "$message", "$headers")) ++$success; else ++$failure; } $mtg->success("Message sent to " . $mtg->format($success) . " user" . $mtg->s($success) . ". Failed to send to " . $mtg->format($failure) . " user" . $mtg->s($failure)); } if (array_key_exists('gd', $_POST)) { $db->query("SELECT id, email FROM gdemails ORDER BY id ASC LIMIT 2"); $db->execute(); $rows = $db->fetch_row(); $success = 0; $failure = 0; echo 'Sending...<br />'; $message = stripslashes($_POST['message']); foreach ($rows as $row) { $email = $row['email']; if (mail("$email", "A message from MS", "$message")) ++$success; else ++$failure; } $mtg->success("Message sent to " . $mtg->format($success) . " user" . $mtg->s($success) . ". Failed to send to " . $mtg->format($failure) . " user" . $mtg->s($failure)); } $pages = new Paginator(); if($_GET['view'] == "grpgusers") { $db->query("SELECT COUNT(id) FROM grpgusers"); $submit = "ms"; } else { $db->query("SELECT COUNT(id) FROM gdemails"); $submit = "gd"; } $db->execute(); $pages->items_total = $db->fetch_single(); $pages->mid_range = 5; $pages->paginate(); ?> <tr><th class='contenthead'>Mass Email</th></tr> <tr><td class='contentcontent'> <form action='staff_mail.php' method='post'> <table id='mttable' width='100%'> <tr> <th width='25%'>Message</th> <td width='75%'><textarea name='message' rows='10' cols='60'></textarea></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='<?php echo $submit; ?>' value='Send Email' /></td> </tr> </table> </form> <br /> <div class='paginate'><?php echo $pages->display_pages(); ?></div> <br /> <form action="staff_mail.php" method="get"> <table width="100%" id='mttable'> <tr> <th width='25%'>Emailer List</th> <td width='75%'><select name='view' onchange='this.form.submit()'> <option value='grpgusers'>Select...</option> <?php $c = 0; foreach ($opts as $opt) { printf("<option value='%s'>%s</option>", $opt, $names[$c]); $c++; } ?></select></td> </tr> </table> </form> <br /> <table id='mttable' width='100%'> <tr> <td colspan='5' class='center'><?php if($_GET['view'] == "grpgusers") { echo "MS"; } else { echo "GD"; } ?> Emails</td> </tr> <tr> <th width='5%'>ID</th> <th width='35%'>Username</th> <th width='48%'>Email</th> <th width='12%'>Action</th> </tr><?php if($_GET['view'] == "grpgusers") { $db->query("SELECT id, username, email FROM grpgusers ORDER BY id ASC " . $pages->limit); } else { $db->query("SELECT * FROM gdemails ORDER BY emailid ASC " . $pages->limit); } $db->execute(); $rows = $db->fetch_row(); foreach ($rows as $row) { ?><tr> <td><?php echo $row['id']; ?></td> <td><?php echo $row['username']; ?></td> <td><?php echo $row['email']; ?></td> <td><?php echo '[Delete]'; ?></td> </tr><?php } ?></table> <br /> <div class='paginate'><?php echo $pages->display_pages(); ?></div> </td></tr><?php require_once __DIR__ . '/footer.php'; m missing something dumb so be gentle with me.
-
Barand's option by far was much much easier and it looks nice as well. Simple and functional is always better than sloppy and complex. Thanks!
-
haha touche! Let me see what I can whip up. Really wanted to do it this way but I will modify it the way Barand mentioned... The easy way inst always the fun way!
-
So is the answer that it cant be done in this manner?
-
Yes that would be an option and a quite simple one but with almost 3000 users and 25 days would give me 75000 rows and I didn't want all that clutter.
-
Okay below is the script I have built in its entirety. It is nowhere near done because I have only got to this last and final point of the functionality. I know I am needing a foreach loop but not 100% on how to go about making it work properly. <?php include "header.php"; genHead("Advent Calendar"); $days = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ); $box = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ); if ($_GET['day']) { $time = date("d", time()); if ($_GET['day'] > 25 || $_GET['day'] < 1) { $msg = 'Nice try there is no gift available for that day!'; } elseif ($time < $_GET['day']) { $msg = 'To soon you can wait to open this day!'; } elseif ($time > $_GET['day']) { $msg = 'Sorry you missed this day try again next year!'; } else { $db->query("SELECT * FROM adventcal_2016 WHERE uid = ?"); $db->execute(array( $user_class->id )); $entry = $db->fetch_row(true); $open_day = explode(",", $entry[open_day]); $opened = $open_day[$_GET['day'] - 1]; $update = implode(",", $opened); $db->query("UPDATE adventcal_2016 SET open_day = ? WHERE uid = ?"); $db->execute(array( $update, $user_class->id )); $msg = 'You have opened day ' . $_GET['day'] . ' and received x points and $x ' . $entry[open_day] . '!'; } } $db->query("SELECT uid FROM adventcal_2016 WHERE uid = ?"); $db->execute(array( $user_class->id )); $entry = ($db->fetch_single()) ? true : false; if (empty($entry)) $db->query("INSERT INTO adventcal_2016 (uid) VALUES (?)"); $db->execute(array( $user_class->id, )); echo "<div class='success'>",$msg,"<br /></div>"; if ($user_class->id != 2) { $mtg->error("You don't have access"); } else { echo '<table cellpadding="5" align="center">'; echo '<tr>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td>' . showDay(1, $box) . '</td>'; echo '<td>' . showDay(2, $box) . '</td>'; echo '<td>' . showDay(3, $box) . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>' . showDay(4, $box) . '</td>'; echo '<td>' . showDay(5, $box) . '</td>'; echo '<td>' . showDay(6, $box) . '</td>'; echo '<td>' . showDay(7, $box) . '</td>'; echo '<td>' . showDay(8, $box) . '</td>'; echo '<td>' . showDay(9, $box) . '</td>'; echo '<td>' . showDay(10, $box) . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>' . showDay(11, $box) . '</td>'; echo '<td>' . showDay(12, $box) . '</td>'; echo '<td>' . showDay(13, $box) . '</td>'; echo '<td>' . showDay(14, $box) . '</td>'; echo '<td>' . showDay(15, $box) . '</td>'; echo '<td>' . showDay(16, $box) . '</td>'; echo '<td>' . showDay(17, $box) . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>' . showDay(18, $box) . '</td>'; echo '<td>' . showDay(19, $box) . '</td>'; echo '<td>' . showDay(20, $box) . '</td>'; echo '<td>' . showDay(21, $box) . '</td>'; echo '<td>' . showDay(22, $box) . '</td>'; echo '<td>' . showDay(23, $box) . '</td>'; echo '<td>' . showDay(24, $box) . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>' . showDay(25, $box) . '</td>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td> </td>'; echo '<td> </td>'; echo '</tr>'; echo '</table>'; } function showDay($num, $todaysbox) { global $user_class, $db; $db->query("SELECT open_day FROM adventcal_2016 WHERE uid = ?"); $db->execute(array( $user_class->id )); $entry = $db->fetch_row(true); $open_day = explode(",", $entry[open_day]); $open = $open_day[$num - 1]; $rtn = '<table onclick=\'document.location="?day=' . $num . '"\' onmouseover="this.style.border=\'solid 2px #999\';" onmouseout="this.style.border=\'solid 2px #000\';" style="background-color:#000;border:solid 2px #000;" width="100">'; $rtn .= '<tr style="background-color:#ddd;color:#000;">'; if ($open == 1) $rtn .= '<td align="center" height="18" style="color:red;"><b>Opened</b>'; else $rtn .= '<td align="center" height="18" style="color:green;"><b>Not Opened</b>'; $rtn .= '</td></tr>'; $rtn .= '<tr><td align="center" style="color:#fff;font-size:18pt;">' . $num . '<br /></td></tr></table>'; return $rtn; } include "footer.php"; ?> The user database table is adventcal_2016 with 3 columns uid, which is the users ID $user_class->id, the id which is just a unique int11 incremental ID, and finally the open_day which is a varchar50 that contains 50 characters by default all zeros like so 0,0,0,0,0,0,0,0,0,0, etc.. I need to update each of the zeros and change them to ones upon opening the box for each day. That is where I am in this project. Any and all help is appreciated.
-
Okay I stepped away from the office to go home as soon as I get there is will post the entire script along with the database structure.
-
it simplifies the database table. Its a temporary table for an advent calendar only used in December and I didn't want to make each day into a separate column. If I showed you the rest of the script you would understand better why I have done it this way.
-
Essentially what I am trying to do here is update my database table where the column open_day contains 25 0's and 25 commas like this 0,0,0,0,0,0,0, etc... I want to update the array position where $_GET('day') - 1 is the correct position for that day. if ($_GET['day']) { $time = date("d", time()); if ($_GET['day'] > 25 || $_GET['day'] < 1) { $msg = 'Nice try there is no gift available for that day!'; } elseif ($time < $_GET['day']) { $msg = 'To soon you can wait to open this day!'; } elseif ($time > $_GET['day']) { $msg = 'Sorry you missed this day try again next year!'; } else { $db->query("SELECT * FROM adventcal_2016 WHERE uid = ?"); $db->execute(array( $user_class->id )); $entry = $db->fetch_row(true); $open_day = explode(",", $entry[open_day]); $opened = $open_day[$_GET['day'] - 1]; $update = implode(",", $opened); $db->query("UPDATE adventcal_2016 SET open_day = ? WHERE uid = ?"); $db->execute(array( $update, $user_class->id )); $msg = 'You have opened day ' . $_GET['day'] . ' and received x points and $x!'; } }
-
That was the issue. I had stored a permanent variable in the cache and of coarse it would not update. I fixed it though with this: if (!$m->get('membersonline.' . $user_class->gang)) { $db->query("SELECT COUNT(id) FROM grpgusers WHERE gang = ? AND lastactive >= ?"); $db->execute(array( $user_class->gang, time() - 900 )); $membersonline = $db->fetch_single(); $m->set('membersonline.' . $user_class->gang, $membersonline, 1); } else $membersonline = $m->get('membersonline.' . $user_class->gang); of coarse I enabled this after destroying the old variable. Thanks for your reply!
-
function callback($buffer) { global $user_class, $db, $m; if (!$m->get('membersonline.' . $user_class->gang)) { $db->query("SELECT COUNT(id) FROM grpgusers WHERE gang = ? AND lastactive >= ?"); $db->execute(array( $user_class->gang, time() - 900 )); $membersonline = $db->fetch_single(); $m->set('membersonline.' . $user_class->gang, $membersonline); } else $membersonline = $m->get('membersonline.' . $user_class->gang); $buffer = str_replace("<!_-monline-_!>", $membersonline ? "<font color='yellow'><strong>" . prettynum($membersonline) . "</strong></font>" : 0, $buffer); return $buffer; } ob_start("callback"); <a href="test.php">Test Line [<!_-monline-_!>]</a> My problem is quite simple but yet I cant figure it out. I want $membersonline to update as people go inactive using the existing format for similar data. Above is just that but as the number increases it just holds to the highest number and never drops lower. i.e. if the value shown is 3 and I check who is online and its 1 why is 3 still showing? Thanks in advance.