| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:53:33 2008 ] | [ PHP Project 1.17 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 include ("connect.php"); 3 include ("loggedin.php"); 4 include ("functions.php"); 5 echo '<title>Edit Category</title></head><body>'; 6 include ("table.php"); 7 8 if (isset($_GET['id']) && $_SERVER['REQUEST_METHOD'] != 'POST') 9 { 10 $id = clean($_GET['id']); 11 if (empty($id) || !is_numeric($id)) 12 die("Please only follow the links on the page."); 13 14 $link = "SELECT * FROM category WHERE id='$id'"; 15 $res = mysql_query($link) or die(mysql_error()); 16 $total = mysql_num_rows($res); 17 18 if ($total == 0) 19 die("Error, invalid record."); 20 21 $link = "SELECT * FROM category WHERE id='$id'"; 22 $res =mysql_query($link) or die(mysql_error()); 23 $row = mysql_fetch_row($res); 24 25 echo '<br /> 26 <form action="" method="POST"> 27 ' . $tablehead . ' 28 <tr> 29 <td class="heading" colspan="2">edit category</td> 30 </tr> 31 <tr> 32 <td>name</td> 33 <td><input type="text" name="cat" value="' . $row[0] . '"></td> 34 </tr> 35 <tr> 36 <td><input type="checkbox" name="delete">delete</td> 37 <td><input type="submit" value="Update Category"> 38 <input type="hidden" name="id" value="' . $id . '"> 39 </td> 40 </tr></form> 41 </table> 42 '; 43 } 44 elseif ($_SERVER['REQUEST_METHOD'] == 'POST') 45 { 46 $id = clean($_POST['id']); 47 48 $cat = clean($_POST['cat']); 49 @$delete = $_POST['delete']; 50 51 if ($delete == 'on') 52 { 53 admin(); 54 55 $link = "SELECT * FROM projects WHERE cat='$cat'"; 56 $res = mysql_query($link) or die(mysql_error()); 57 $total = mysql_num_rows($res); 58 if ($total > 0) 59 die("Can not delete this because a project is using it."); 60 61 $link = "DELETE FROM category WHERE id='$id'"; 62 $res = mysql_query($link) or die(mysql_error()); 63 if ($res) 64 die('Category Succesfully Deleted.<br />Click <a href="index.php">here</a> to go back.'); 65 } 66 67 if (empty($cat)) 68 die("Please go back and enter a status."); 69 70 $link = "UPDATE category SET cat='$cat' WHERE id='$id'"; 71 $res = mysql_query($link) or die(mysql_error()); 72 if ($res) 73 die('<p>succesfully updated.<br />click <a href="cat.php">here</a> to continue.</p>'); 74 } 75 else 76 die('You should not be seeing this.<br />Click <a href="index.php">here</a> to go back.'); 77 ?> 78 79
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |