Jump to content

[SOLVED] Trying To Alter Table And Unsuccesful: Am I Missing Something?


refiking

Recommended Posts

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]

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">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.