The page loads with the form.
You select March from the dropdown list.
You click next.
On the following page it checks the database for the word in $month (namely, March) in the database field named 'month', and for 'yes' in the field named 'paid'.
I can tell you that March is not mentioned in the table at all.
The word 'paid' does have 'yes' in it, but not in a field containing 'March'.
Does the SQL need brackets or something, as it appears to be producing an impossible answer.
Code: Select all
<?php
$cookietype = $_COOKIE['type'];
$cookieid = $_COOKIE['userid'];
$month = $_POST['month'];
if ($cookietype == "advertiser" || $cookietype == "admin")
{
include "dbconn.php";
if ($month != NULL)
{
$result = mysql_query ("SELECT COUNT(id) AS numrows FROM adverts WHERE month = '$month' AND paid = 'yes'");
if (mysql_num_rows($result)==0) { echo "<b>There are no adverts booked for $month</b>";}
elseif (mysql_num_rows($result)!=0) { echo "<b>There are $numrows adverts booked for $month</b>";}
echo "<br/><br/>If you would like to continue with advertising for this month, click 'Next'. If not, click 'Restart'.<br/><br/>
<table><tr><td>
<form method='post' action='index.php?page=advertadd1pay&menu=advert&head=create advert'>
<input type='hidden' name='month' value='$month'>
<input type='submit' value='Next'>
</form></td><td>
<form method='post' action='index.php?page=advertadd1&menu=advert&head=create advert'>
<input type='submit' value='Restart'>
</form></td></tr></table>
";
mysql_free_result($result);
}
elseif ($month == NULL)
{
$today = (date("Y-m-d"));
$month = substr("$today",-5,2);
echo "<form method='post' action='index.php?page=advertadd1&menu=advert&head=create advert'>
Please select the month for which you would like your advert shown.<br/><br/>
<select name='month'>
<option value='January'>January</option>
<option value='February'>February</option>
<option value='March'>March</option>
<option value='April'>April</option>
<option value='May'>May</option>
<option value='June'>June</option>
<option value='July'>July</option>
<option value='August'>August</option>
<option value='September'>September</option>
<option value='October'>October</option>
<option value='November'>November</option>
<option value='December'>December</option>
</select>
<input type='submit' value='Next'>
</form>";
}
$result = mysql_query ("SELECT id FROM adverts WHERE userid = '$cookieid' AND paid = 'yes'");
$num_rows = mysql_num_rows($result);
echo "<br/><div class='usercommentsform'>You have $num_rows adverts live.</div>";
mysql_free_result($result);
mysql_close($sqlconn);
}
else
{
echo "<meta http-equiv='Refresh' content='0 ;URL=index.php?page=home&menu=home'>";
}
?>There are adverts booked for March
If you would like to continue with advertising for this month, click 'Next'. If not, click 'Restart'.