refiking Posted February 1, 2008 Share Posted February 1, 2008 I am trying to update the rules table in a db and for some reason, it is not responding. I triple checked the table and fields to make sure they are the same and they are. Here's the code: The section I am talking about is at the bottom of the code and it redirects, but does not alter the table: <?php //include 'access.php'; include 'cont.php'; $ruleid = $_GET['ruleid']; $type = $_GET['type']; IF ($type == "del"){ mysql_query("INSERT INTO rulearchive (rule) VALUES ('$rule')"); mysql_query("DELETE FROM rules WHERE rule_id='$ruleid'"); header("Location: index.php"); } IF ($type == "edit"){ ?> <html> <body bgcolor="sky blue"> <table> <form action="ruleconfirm.php?type=editc" method="post"> <font color="navy"><b>Please edit the rule:</b><br> <input type="hidden" name="ruleid" value='<?echo $ruleid;?>'> <textarea name="rule" rows="10" cols="30"> <?$sql = mysql_query("SELECT * FROM rules where rule_id = '$ruleid'"); while($row = mysql_fetch_assoc($sql)) { ?> <?echo $row['rule'];}?></textarea> <br> <input type="submit" value="edit"> </form> </table> <? } IF ($type == "editc"){ $rule = $_POST['rule']; $check = mysql_query("UPDATE rules SET rule = '$rule' WHERE rule_id = '$ruleid'")or die(mysql_error()); IF ($check){ header("Location: index.php"); } ELSE { Echo "Unsuccessful"; } } ?> [/codel] Link to comment https://forums.phpfreaks.com/topic/88897-solved-trying-to-alter-table-and-unsuccesful-am-i-missing-something/ Share on other sites More sharing options...
rhodesa Posted February 1, 2008 Share Posted February 1, 2008 When you submit your form, the only variable stored in $_GET will be 'type' = 'editc'. Change your form tag to this: <form action="ruleconfirm.php?ruleid=<? echo $ruleid; ?>&type=editc" method="post"> Link to comment https://forums.phpfreaks.com/topic/88897-solved-trying-to-alter-table-and-unsuccesful-am-i-missing-something/#findComment-455347 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.