hance2105 Posted July 27, 2013 Share Posted July 27, 2013 hello,i have below code and i need to change the status to inactive when i press the delete button. it happens that when i use the code below, the status does not change at all. can anyone tell me where am having an error in the code? <?php session_start(); include_once("db_connect.php"); if(isset($_POST['delete'])) { $prod_id=$_POST['prod_id']; $prod_name=$_POST['prod_name']; $prod_brand=$_POST['prod_brand']; $prod_desc=$_POST['prod_desc']; $prod_w_c=$_POST['prod_w_c']; //updating the table $result=mysql_query("UPDATE tblproduct SET status='inactive' WHERE prod_id='".$prod_id."';"); header("Location: del_updprod.php"); } ?> <?php $prod_id = $_GET['prod_id']; $result=mysql_query("SELECT * FROM tblproduct where prod_id = ".$prod_id." AND status = 'active'") or die(mysql_error()); ?> <html> <title>Delete Product</title> <body background="Images/contentbg.jpg"> <a href="del_updprod.php"><img src="Images/back button.png" width="100" /></a> <br/><br/> <form name="edit" method="post" action="del_prod.php"> <table align="center" border="0"> <?php while($res=mysql_fetch_array($result)) { $prod_name=$res['prod_name']; $prod_brand=$res['prod_brand']; $prod_desc=$res['prod_desc']; $prod_w_c=$res['prod_w_c']; ?> <tr> <td>Product Name</td> <td> <input type="text" name="prod_name" value = "<?php echo $prod_name;?>"> </td> </tr> <tr> <td>Product Brand</td> <td> <input type="text" name="prod_brand" value = "<?php echo $prod_brand;?>"> </td> </tr> <tr> <td>Product Description</td> <td> <textarea rows="5" cols="50" name="ret_city"><?php echo $prod_desc;?></textarea> </td> </tr> <tr> <td>Product Weight/Capacity</td> <td> <input type="text" name="prod_w_c" value = "<?php echo $prod_w_c;?>"> </td> </tr> <?php } ?> <tr> <td><input type="submit" name="delete" value="Delete"></td> </tr> </table> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted July 27, 2013 Share Posted July 27, 2013 Well, what is the file's name of that script?Do you know that the action of your html form goes to the file, called - "del_updprod.php"? If that file's name is different nothing from here will be executed. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 27, 2013 Share Posted July 27, 2013 I don't see a form field called 'prod_id' so there will be no $_POST['prod_id'] Quote Link to comment 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.