thefreebielife Posted May 23, 2007 Share Posted May 23, 2007 <? //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 = $r['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 $ooi == "") { $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 = $r['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++; } ?> i know its long but this form is VERY important to me. ever since i added the "ocost" stuff nothing has worked. nothing is being posted to the database. does anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/ Share on other sites More sharing options...
trq Posted May 23, 2007 Share Posted May 23, 2007 does anyone have any ideas? Try some debugging and be more descriptive / informative about what is and isn't happening. Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259469 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 well i added the "ocost" and "oocost" and made a new input to allow it to post to ocost in my database. now ever since that isnt working and whenever i try to add a completly new offer it isnt posting to the DB either Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259475 Share on other sites More sharing options...
trq Posted May 23, 2007 Share Posted May 23, 2007 Sorry, but for starters... narrow your code down to something that we can be bothered looking at. Next... are you getting any errors? If not, make sure you have error_reporting and display_errors enabled. And please... use <?php tags, not only to enable syntax highlighting in the forum, but to ensure your code will work on modern servers. Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259482 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 <?php 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); $ocost = $r['ocost']; } if (isset($_GET["form"]) && $_GET["form"] == "change") { $error = "none"; $oocost = $are['ocost']; $ooi=$_POST['i']; print "abcdefg"; print $_POST['oWeight']; //validate { $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"; $ocost = $are['ocost']; //validate if ($error == "none") { $d = $od; $insert = mysql_query("insert into offers values ('', '$ocampid', '$oname', '$d', '$olink', '$oimage', '$oi', '$owait','$oweight', '$ocost')") ?> <form action="<? if (isset($_GET['change'])) { ?>aoffers.php?form=change <? } else { ?>aoffers.php?form=submit <? } ?>" method="post" name="addoffers" enctype="multipart/form-data"> <tr> <td width="146">Offer Cost:</td> <td width="278"><input name="cost" type="text" id="cost" value="<? echo "$ocost"; ?>" size="20" /></td> </tr> <? //select the table $result = mysql_query("select * from offers order by oname"); $i = 1; //grab all the content while($are=mysql_fetch_array($result)) { $oid = $r['oId']; $ocost = $r['ocost']; $uId = 1; ?> <tr><td><div class="gprice" align="left"><font color="#000000">Cost: </font> <? echo "$ocost"; ?><br></td></tr> </table></Td> php?> okay there. the strings with "ocost" or something along those lines i added. i did not touch anything else Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259503 Share on other sites More sharing options...
textbox Posted May 23, 2007 Share Posted May 23, 2007 Just as a quick glance, is this correct? $oocost = $are['ocost']; Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259504 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 no, they are supposed to be $r i dont know why theyre showing up like that Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259505 Share on other sites More sharing options...
textbox Posted May 23, 2007 Share Posted May 23, 2007 Sorry i should have made it more obvious. $oocost = $are['ocost']; oocost 2 o's? Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259506 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 well thats only for the change form. should i take away an "o"? but the $r value still points to ocost Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259510 Share on other sites More sharing options...
textbox Posted May 23, 2007 Share Posted May 23, 2007 You could try it. I just spotted it and thought it was odd. Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259512 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 i tired- same problem. this problem only happened when i added the ocost Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259515 Share on other sites More sharing options...
trq Posted May 23, 2007 Share Posted May 23, 2007 I'll say it again then.... are you getting any errors? If not, make sure you have error_reporting and display_errors enabled. Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259516 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 no im not getting any errors. sorry but where do i enable those? i have never used them before Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259520 Share on other sites More sharing options...
thefreebielife Posted May 23, 2007 Author Share Posted May 23, 2007 anyone else have any ideas? or does anyone want to rewrite the script without the "ocost's" and add them in for me? i would really appreciate that Quote Link to comment https://forums.phpfreaks.com/topic/52584-big-time-mess-up-on-major-form-on-my-site/#findComment-259669 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.