Location: PHPKode > scripts > Hot or Not Clone > hotornot/control/addcategory.php
<?
include("../config.php");
include("checksession.php");

function getCategories($catid,$level)
{
	global $appendstr;
	{
		$sql="select * from category where categoryid=$catid";
		$result=mysql_query($sql);
		if($obj=mysql_fetch_object($result))
		{
			$appendstr=$appendstr."<option value='$catid'>";
			$spacer="";
			for($i=0;$i<$level;$i++)
			$spacer=$spacer."&nbsp;&nbsp;&nbsp;&nbsp;";
			$appendstr=$appendstr.$spacer.$obj->catname."</option>\n";
		}
	}
	
		$sql="select * from category where parent=$catid";
		$result=mysql_query($sql);
		while($obj=mysql_fetch_object($result))
		{
			$catid=$obj->categoryid;
			getCategories($catid,($level+1));
		}

}

if(trim($catname)!="")
{
	$sql="insert into category(catname,parent,description,adminaccess) values('$catname',$parent,'$desc','$adminaccess')";
	mysql_query($sql);
	$success="1";
}
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="stylesheet.css" type="text/css">

<title>Control Panel</title>
<script language="JavaScript">

function checkifvalid(){
if (window.document.myform.catname.value=="")
{
alert("please enter the Category Name");
window.document.myform.catname.focus();
return false;
}
return true;
}
</script>
</head>
<script language="JavaScript">
 <?php
    if(isset($success))
    {
		print("alert('Category Added!');");
	}
    ?>
</script>
</head>

<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FCFAF7" text="#000000" >

<div align="left"> 
  <table border="0" cellpadding="0" cellspacing="0" width="100%" height="41">
    <tr> 
      <td width="150%" bgcolor="#000000" height="1"></td>
    </tr>
    <tr > 
      <td width="100%" align="left" valign="bottom" bgcolor="#FFFFFF" class="topheader"  > 
        Control Panel </td>
    </tr>
  </table>
</div>

<div align="left"> 
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td width="20%" align="left" valign="top"> 
        <? include("sidelinks.php"); ?>
      </td>
      <td width="80%" valign="top" align="center"><br>
<br>
        <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr> 
            <td height="239">
<div align="center"> 
                <table width="88%" height="10" border="0" cellpadding="0" cellspacing="0" class="mytable">
                  <tr> 
                    <td><div align="center"> 
                        <table border="0" width="100%" height="100%">
                          <form name="myform"  method="post" action="addcategory.php" onsubmit="javascript: return checkifvalid();">
                            <tr > 
                              <td height="19" colspan="2" class="header">Add Category</td>
                            </tr>
                            <tr> 

                              <td width="37%" height="19"><font face="Verdana" size="2">Parent 
                                category </font></td>
                              <td width="63%" height="19"><select name="parent" id="parent">
                                  <option value="0">Root</option>
								  <? $appendstr=""; getCategories(0,"",0); print $appendstr;?>
                                </select></td>
                            </tr>
                            <tr> 
                              <td height="19"><font face="Verdana" size="2">Category 
                                Name </font></td>
                              <td height="19"><input name="catname" type="text" id="catname3"></td>
                            </tr>
                            <tr> 
                              <td height="19"><font face="Verdana" size="2">Description</font></td>
                              <td height="19"><textarea name="desc" id="desc"></textarea></td>
                            </tr>
                            <tr> 
                              <td height="19"><font face="Verdana" size="2">Allow 
                                only admin to access</font></td>
                              <td height="19"> <input type="radio" name="adminaccess" value="Y">
                                Yes <input name="adminaccess" type="radio" value="N" checked>
                                No</td>
                            </tr>
                            <tr> 
                              <td colspan="2" height="17"> <p align="center"> 
                                  <input type="submit" name="Submit" value="Add Category">
                              </td>
                            </tr>
                          </form>
                        </table>
                      </div></td>
                  </tr>
                </table>
              </div></td>
          </tr>
        </table></td>
    </tr>
	
  </table>
</div>
</body>

</html>
<? include("conclose.php"); ?>
Return current item: Hot or Not Clone