Ever since i added all the "cost" stuff.. nothing will post. i cant add new offers, and to top it off, cost doesnt work.
There are no errors in my log so i dont know what to do. Pleassee help me:
<? //edit gift
if (isset($_GET['change'])) {
$num = $_GET['change'];
$data2 = mysql_query("SELECT * FROM `offers` WHERE oId='$num'")
or die(mysql_error());
$r = mysql_fetch_array($data2);
$oname = $r['oName'];
$ocampid = $r['oCampID'];
$od = $r['oDescription'];
$olink = $r['oLink'];
$owait = $r['oWait'];
$oi = $r['oInstructions'];
$oimage = $r['oImage'];
$oweight = $r['oWeight'];
$ocost = $r['ocost'];
}
if (isset($_GET["form"]) && $_GET["form"] == "change")
{
$error = "none";
$ooname = $_POST['name'];
$ood = $_POST['description'];
$oolink = $_POST['link'];
$oocampid = $_POST['oCampID'];
$oowait = $_POST['wait'];
$ocredit = $r['oCredit'];
$ooimage = $_POST['image'];
$num = $_POST['offerid'];
$ooweight = $_POST['oWeight'];
$oocost = $_POST['ocost'];
$ooi=$_POST['i'];
print "abcdefg";
print $_POST['oWeight'];
//validate
if (!other_fields($ooname) or $ooname == "") { $error = "name"; }
if (!other_fields($ood) or $ood == "") { $error = "description"; }
if (!other_fields($oocost) or $oocost == "") { $error = "cost";}
if (!other_fields($oowait) or $oowait == "") { $error = "wait"; }
if (!other_fields($ooi) or $ooi == "") { $error = "instructions";}
if ($error == "none")
{
$d = $ood;
$query="UPDATE offers SET oName='$ooname', oCampID='$oocampid', oDescription='$d', oWait='$oowait', oImage='$ooimage', oLink='$oolink', oInstructions='$ooi',oweight='$ooweight',ocost='$oocost' WHERE oId='$num'";
mysql_query($query) or die("Could not insert data because ".mysql_error());
echo '<div align=center><font color=red>Offer Updated</font></div>';
echo '<meta http-equiv="refresh" content="1;url=aoffers.php">';
}
}
?>
<? //validate form
//get vars
if (isset($_GET["form"]) && $_GET['form'] == "submit") {
$error = "none";
$oname = $_POST['name'];
$ocampid = $_POST['oCampID'];
$od = $_POST['description'];
$olink = $_POST['link'];
$owait = $_POST['wait'];
$oi = $_POST['i'];
$oimage = $_POST['image'];
$oweight =$_POST['oWeight'];
$ocost = $_POST['ocost'];
//validate
if (!other_fields($oname) or $oname == "") {
$error = "name";
}
if (!other_fields($od) or $od == "") {
$error = "description";
}
if (!other_fields($owait) or $owait == "") {
$error = "wait";
}
if (!other_fields($oi) or $oi == "") {
$error = "instructions";
}
if (!other_fields($ocost) or $ocost == "") {
$error = "cost";
}
if ($error == "none") {
$d = $od;
$insert = mysql_query("insert into offers values ('', '$ocampid', '$oname', '$d', '$olink', '$oimage', '$oi', '$owait','$oweight',
'$ocost')")
or die("Could not insert data because ".mysql_error());
echo '<center><font color="#ff0000"><h4>The Offer Has Been Entered Into The Database</h4>';
echo '<meta http-equiv="refresh" content="1;url=aoffers.php">';
}
}
?>
<form action="<? if (isset($_GET['change'])) { ?>aoffers.php?form=change <? } else { ?>aoffers.php?form=submit <? } ?>" method="post" name="addoffers" enctype="multipart/form-data">
<table border="0" align="center" style="border: 1px dashed red; padding: 4px 4px 4px 4px;">
<tr>
<td colspan="2">
<? if ($error == "name") { echo "<center><font color=red> Error in the name field</font></center>"; }
if ($error == "description") { echo "<font color=red><center> Error in the Description field</center></font>"; }
if ($error == "wait") { echo "<font color=red><center> Error in the Wait Field</center></font>"; }
if ($error == "instructions") { echo "<font color=red><center> Error in the Instructions field</center></font>"; }
?>
<tr>
<td colspan="2"><div align="center"><strong>Add An Offer</strong></div></td>
</tr>
<tr>
<td width="146">Offer Name:</td>
<td width="278"><input name="name" type="text" id="name" value="<? echo "$oname"; ?>" size="40" /></td>
</tr>
<tr>
<td width="146">Offer Campaign ID:</td>
<td width="278"><input name="oCampID" type="text" id="oCampID" value="<? echo "$ocampid"; ?>" size="40" /></td>
</tr> <tr>
<td width="146">Offer Link: <font color="#FF0000"> </font></td>
<td width="278"><input name="link" type="text" id="link" value="<? echo "$olink"; ?>" size="40" /></td>
</tr>
<tr>
<td width="146">Offer Instructions:</td>
<td width="278"><input name="i" type="text" id="i" value="<? echo "$oi"; ?>" size="40" /></td>
</tr>
<tr>
<td width="146">Offer Image URL:</td>
<td width="278"><input name="image" type="text" id="image" value="<? echo "$oimage"; ?>" size="40" /></td>
</tr>
<tr>
<td nowrap="nowrap">Offer Description:</td>
<td><textarea name="description" cols="30" rows="10" id="description"><? echo "$od"; ?></textarea></td>
</tr>
<tr>
<td nowrap="nowrap">Offer Wait Time:</td><td>
<input name="wait" type="text" id="wait" value="<? echo "$owait"; ?>" size="40" /></td>
</tr>
<tr>
<td nowrap="nowrap">Offer Weight : </td><td>
<select name = "oWeight">
<option value="1/4" <?if($oweight=='1/4') echo "selected"; ?> >1/4 </option>
<option value="1/3" <?if($oweight=='1/3') echo "selected"; ?> > 1/3 </option>
<option value="1/2" <?if($oweight=='1/2') echo "selected"; ?> > 1/2 </option>
<option value="2/3" <?if($oweight=='2/3') echo "selected"; ?> > 2/3 </option>
<option value="3/4" <?if($oweight=='3/4') echo "selected"; ?> > 3/4 </option>
<option value="1/1" <?if($oweight=='1/1') echo "selected"; ?> > 1/1 </option>
</select>
</tr>
<tr>
<td width="146">Offer Cost:</td>
<td width="278"><input name="cost" type="text" id="cost" value="<? echo "$ocost"; ?>" size="20" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="submit" type="submit" value="Submit" />
<input name="offerid" type="hidden" id="offerid" value="<? echo "$num"; ?>">
</div></td>
</tr>
</table>
</form>
<div class="border"></div><br>
<table align="center">
<Tr>
<?
//select the table
$result = mysql_query("select * from offers order by oname");
$i = 1;
//grab all the content
while($r=mysql_fetch_array($result))
{
$oid = $r['oId'];
$ocampid = $r['oCampID'];
$oname = $r['oName'];
$od = $r['oDescription'];
$olink = $r['oLink'];
$owait = $r['oWait'];
$oi = $r['oInstructions'];
$oimage = $r['oImage'];
$oweight= $r['oweight'];
$ocost = $r['ocost'];
$uId = 1;
?>
<Td><Table style="width:220px; margin-left:35px;" height="300"><tr><td><div align="center"><a href="<? echo "$olink"."$uId"; ?>"><img src="<? echo "$oimage"; ?>" border="0"></a></div></td></tr>
<tr><td><div class="gname"><? echo "$oname"; ?></div></td></tr>
<tr><td><div class="gname"><? echo "$ocampid"; ?></div></td></tr>
<tr><td><div class="odescription"><? echo stripslashes($od); ?></div></td></tr>
<tr><td><div class="odescription"><strong>Instructions: </strong><? echo $oi; ?></div></td></tr>
<tr><td><div class="gprice" align="left"><font color="#000000">Approval: </font> <? echo "$owait"; ?><br></td></tr>
<tr><td><div class="gprice" align="left"><font color="#000000">Weight: </font> <? echo "$oweight"; ?><br></td></tr>
<tr><td><div class="gprice" align="left"><font color="#000000">Cost: </font> <? echo "$ocost"; ?><br></td></tr>
<tr><td><div align="center"><font color="#000000"><a href="aoffers.php?change=<? echo "$oid"; ?>">Edit Offer</a></font></div></td></tr>
<tr><td><div align="center"><font color="#000000"><a href="aoffers.php?remove=<? echo "$oid"; ?>">Remove Offer</a></font></div></td></tr>
</table></Td>
<?
if ($i % 3 == 0) { echo "</tr><tr>"; }
$i++;
}
?>