?
Path : /home/admin/public_html/old/membershop/admin/ |
Current File : /home/admin/public_html/old/membershop/admin/category.php |
<?PHP include ("../functions.php"); if (is_logged_in_admin($admin)) { function Listcategory(){ global $db, $prefix, $page; include("header.php"); //if the shop is logged in then read the cookies. $cookie_read = explode("|", base64_decode($admin)); //define variables to hold cookie values. $adminid = $cookie_read[0]; $admin_name = $cookie_read[1]; $password = $cookie_read[2]; $ipaddress = $cookie_read[3]; $lastlogin_date = $cookie_read[4]; $lastlogin_time = $cookie_read[5]; $cookie_read = explode("|", base64_decode($shop)); $result = $db->sql_query("SELECT * FROM ".$prefix."_category"); //Menu echo "<td width=20% align=left>"; nav_menu(); echo "</td><td align=center width=80%>"; //End Menu echo "<center> <table align=\"center\" border=\"0\" width=\"100%\" id=\"table2\" cellpadding=\"0\"> <tr><td align=\"left\"><font class=\"title\">Category</font></td><td align=\"right\">[ <a href=category.php?action=Addcategory>Add new</a> ]</td></tr></table> <table align=\"center\" border=\"1\" width=\"100%\" id=\"table1\" cellpadding=\"2\" bordercolor=\"#C0C0C0\"> <tr bgcolor=#098bcf> <td width=\"10\" align=\"center\"><font size=3 color=#ffffff><b>#</b></font></td> <td align=\"center\"><font size=3 color=#ffffff><b>Category Name</b></font></td> <td width=\"20\" align=\"center\"><font size=3 color=#ffffff><b>Options</b></font></td> </tr>"; $countno = 0; while ($row=mysql_fetch_array ($result)) { $countno = $countno + 1; echo "<tr> <td align=\"center\">$countno</td> <td align=\"center\">$row[cat_name]</td> <td align=\"center\">[<a href=\"category.php?action=Editcategory&cat_id=$row[cat_id]\">Edit/View</a>] [ <a href=\"javascript:jsdel('category.php?action=delcategory&cat_id=$row[cat_id]')\">Del</a> ] </td> </tr>"; }//end while echo "</table>"; include("footer.php"); } function Addcategory(){ include ("header.php"); global $categorytxt; //Menu echo "<td width=150px align=left>"; nav_menu(); echo "</td><td align=center>"; //End Menu echo "<center><font class=\"title\">Add new category</font></center><br>\n"; echo "<center>"._FILED_STAR_REQUIRED." <form name=\"categoryForm\" method=\"POST\" action=\"category.php\" enctype=\"multipart/form-data\"> <table align=\"center\" border=\"1\" width=\"100%\" id=\"table1\" cellpadding=\"2\" bordercolor=\"#C0C0C0\"> <tr> <td width=\"25%\" align=\"right\">Category Name :</td> <td><input type=\"text\" name=\"categorytxt\" size=\"50\" value=\"\"> * </td> </tr> <tr> <td> </td> <td> <input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\"> <input type=\"hidden\" name=\"action\" value=\"do_Addcategory\"> <input type=\"submit\" value=\"SEND\"></td> </tr> </table> </form> <center>"._GOBACK." "._GOHOME."</center>"; include ("footer.php"); } function do_Addcategory(){ global $db, $prefix,$categorytxt,$adminid; include ("header.php"); // save data to database $result = $db->sql_query("INSERT INTO ".$prefix."_category (cat_name) " ." VALUES('$categorytxt')"); // back index page msg_redirect("Add New discount Success","category.php","0"); include ("footer.php"); } function Editcategory(){ global $shopid; include("header.php"); EditcategoryForm(); include("footer.php"); } function EditcategoryForm(){ global $prefix,$cat_id,$cat_name,$categorytxt; $result = mysql_query("SELECT * FROM ".$prefix."_category WHERE cat_id='$cat_id'"); $row = mysql_fetch_array($result); $cat_id = $row['cat_id']; $cat_name = $row['cat_name']; //Menu echo "<td width=150px align=left>"; nav_menu(); echo "</td><td align=center>"; //End Menu echo "<center><font class=\"title\">Edit category</font></center><br>\n"; echo "<center>"._FILED_STAR_REQUIRED." <form name=\"categoryForm\" method=\"POST\" action=\"category.php\"> <table align=\"center\" border=\"1\" width=\"100%\" id=\"table1\" cellpadding=\"2\" bordercolor=\"#C0C0C0\"> <tr> <td width=\"25%\" align=\"right\">Category Name :</td> <td><input type=\"text\" name=\"categorytxt\" size=\"50\" value=\"$cat_name\"> *</td> </tr> <tr> <td> </td> <td> <input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\"> <input type=\"hidden\" name=\"action\" value=\"do_Editcategory\"> <input type=\"submit\" value=\"SEND\"></td> </tr> </table> </form> <center>"._GOBACK." "._GOHOME."</center>"; } function delcategory(){ global $db, $prefix, $cat_id; $result = mysql_query("delete from ".$prefix."_category WHERE cat_id='$cat_id'"); include("header.php"); echo "<div align=\"center\" class=\"div\">shop has been deleted. <br>Please wait ...</div>"; echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=category.php\">"; include("footer.php"); } function do_Editcategory(){ global $prefix,$cat_id,$cat_name,$categorytxt; $result = mysql_query("UPDATE ".$prefix."_category SET cat_name='$categorytxt' WHERE cat_id='$cat_id'"); include("header.php"); echo "<div align=\"center\" class=\"div\">Your information has been successfully changed. <br>Please wait ...</div>"; echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=category.php\">"; include("footer.php"); } switch ($action){ case "Addcategory": Addcategory(); break; case "do_Addcategory": do_Addcategory(); break; case "Editcategory": Editcategory(); break; case "do_Editcategory": do_Editcategory(); break; case "delcategory": delcategory(); break; Default: Listcategory(); Break; } ////////////////////////////////// //if the admin is not logged in. }else{ $error_msg = "<font class=\"error\">"._ADMIN_LOGIN_ERR."</font>"; unset($admin_name); unset($password); msg_redirect($error_msg,"index.php","1"); exit(); } ?>