I want to be able to reward my members with credits, banner advertisements, text advertisements and even cash, but on a partially manual basis.
I created a page where I could decide how many members would get a reward, and then update them based on the member id and details I enter, here's the code for the page:
Expand|Select|Wrap|Line Numbers
- <?php
- /**
- * @author Raymond Dube
- * @copyright 2008
- * @version 1.0
- */
- include ('../../system.php');
- function ryg_mailer($message)
- {
- mail("$gReceivingEmail", "Bonus Updater", $message, "From: Bonus Updater\r\nContent-type: text/html; charset=us-ascii");
- return;
- }
- if(!$_POST["save"])
- {
- ?>
- <html>
- <head>
- <title>Bonus Manager</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" type="text/css" href="../css/config.css">
- </head>
- <body>
- <form action='bonus.php' method='POST' name='number_or_members'>
- <table width="100%" class="configuration" bgcolor="#F2F2F2" align="center">
- <tr>
- <th>Bonus Giveaway</th>
- <th>
- <table width="100%">
- <tr>
- <td align="center">
- <input type="button" value="Close Configuration" onClick="window.location.replace('../frames/home.php');" name="close" class="buttonsubmit">
- </td>
- <td>
- <input type="submit" value="Submit" name="save" class="buttonsubmit" style="float: right;">
- </td>
- </tr>
- </table>
- </th>
- </tr>
- <tr>
- <td width="50%" class="c_col_left">How Many Members?<br>
- <font size="1">
- Enter the number of members you want to award bonuses to, then click Submit!
- </font>
- </td>
- <td width="50%" align="center" class="c_col_right">
- <input size="8" value="<? echo $mems; ?>" name="mems">
- </td>
- </tr>
- <tr>
- <th width="100%" colspan="2">
- <p style="text-align: center">
- <input type="submit" value="Submit" name="save" class="buttonsubmit">
- </th>
- </tr>
- </table>
- </form>
- </body>
- </html>
- <?
- }
- if($_POST["save"] == "Submit")
- {
- $mems = $_POST[mems];
- ?>
- <html>
- <head>
- <title>Bonus Manager</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" type="text/css" href="../css/config.css">
- </head>
- <body>
- <form action='bonus.php' method='POST' name='bonus_form'>
- <input type="hidden" name="mems" value="<? echo $mems;?>">
- <table width="100%" class="configuration" bgcolor="#F2F2F2" align="center">
- <tr>
- <th>Bonus Giveaway</th>
- <th>
- <table width="100%">
- <tr>
- <td align="center">
- <input type="button" value="Close Configuration" onClick="window.location.replace('../frames/home.php');" name="close" class="buttonsubmit">
- </td>
- <td>
- <input type="submit" value="Award Members" name="save" class="buttonsubmit" style="float: right;">
- </td>
- </tr>
- </table>
- </th>
- </tr>
- <tr>
- <td width="50%" class="c_col_left">Member IDs<br>
- <font size="1">
- Enter the member id, one id per box please.
- </font>
- </td>
- <td class="c_col_right">
- <table>
- <tr>
- <?
- $i=0;
- while($i < $mems)
- {
- //build table with the number of cells equal to the number of members to update.
- echo "<td><input size=\"8\" value=\"\" name=\"memid[$i]\" id=\"memid[$i]\"></td>";
- $i++;
- }
- ?>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td width="50%" class="c_col_left">Cash<br>
- <font size="1">
- Enter the Cash Amount for each member.
- </font>
- </td>
- <td class="c_col_right">
- <table>
- <tr>
- <?
- $i=0;
- while($i < $mems)
- {
- //build table with the number of cells equal to the number of members to update.
- echo "<td><input size=\"8\" value=\"\" name=\"cashb[$i]\" id=\"cashb[$i]\"></td>";
- $i++;
- }
- ?>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td width="50%" class="c_col_left">Credits<br>
- <font size="1">
- Enter the Credit Amount for each member.
- </font>
- </td>
- <td class="c_col_right">
- <table>
- <tr>
- <?
- $i=0;
- while($i < $mems)
- {
- //build table with the number of cells equal to the number of members to update.
- echo "<td><input size=\"8\" value=\"\" name=\"creds[$i]\" id=\"creds[$i]\"></td>";
- $i++;
- }
- ?>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td width="50%" class="c_col_left">Banners<br>
- <font size="1">
- Enter the Banner Amount for each member.
- </font>
- </td>
- <td class="c_col_right">
- <table>
- <tr>
- <?
- $i=0;
- while($i < $mems)
- {
- //build table with the number of cells equal to the number of members to update.
- echo "<td><input size=\"8\" value=\"\" name=\"bnrs[$i]\" id=\"bnrs[$i]\"></td>";
- $i++;
- }
- ?>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td width="50%" class="c_col_left">Texts<br>
- <font size="1">
- Enter the Text Amount for each member.
- </font>
- </td>
- <td class="c_col_right">
- <table>
- <tr>
- <?
- $i=0;
- while($i < $mems)
- {
- //build table with the number of cells equal to the number of members to update.
- echo "<td><input size=\"8\" value=\"\" name=\"txts[$i]\" id=\"txts[$i]\"></td>";
- $i++;
- }
- ?>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <th width="100%" colspan="2">
- <table width="100%">
- <tr>
- <td align="center">
- <input type="button" value="Reset" onClick="window.location.replace('bonus.php');" name="close" class="buttonsubmit">
- </td>
- <td>
- <input type="submit" value="Award Members" name="save" class="buttonsubmit" style="float: right;">
- </td>
- </tr>
- </table>
- </th>
- </tr>
- </table>
- </form>
- <?
- }
- if($_POST["save"] == "Award Members")
- {
- $mems = $_POST['mems'];
- $i=0;
- while ($i < $mems)
- {
- $memid = $_POST['memid'][$i];
- $cashb = $_POST['cashb'][$i];
- $creds = $_POST['creds'][$i];
- $bnrs = $_POST['bnrs'][$i];
- $txts = $_POST['txts'][$i];
- $GET_SQL = "UPDATE `vtp_members` SET `cash`=`cash`+'$cashb', `hits`=`hits`+'$creds', `banner_total`=`banner_total`+'$bnrs', `text_total`=`text_total`+'$txts' WHERE `id`='$memid'";
- echo "<br>Query: ".$GET_SQL;
- /*$update_result = mysql_query($GET_SQL);
- if (!$update_result)
- {
- $error = "Bonus Update did not function as expected. Member: $membid; Cash: $cashb; Credits: $creds; Banners: $bnrs; Texts: $txts.";
- ryg_mailer($error);
- }*/
- ++$i;
- }
- }
- ?>
Now when I put numbers in these fields, and click submit again, I get incorrect date, in fact, I get the letters that spell Array, so something is wrong, but I just can't seem to see it.
Help! Please! :)
Ray