Php (1)
- 2. PHP PRECTICAL
2HEMANG DESAI
$str="select * from login where username='".$_POST['txtusername']."' and
password='".$_POST['txtpassword']."'";
$res=mysql_query($str);
if (mysql_num_rows($res)>0)
{
$_SESSION['login']=$_POST['txtusername'];
header("location:addcat.php");
}
else
{
$msg="try again";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body bgcolor="#CCCCCC">
<center>
<form id="form1" name="form1" method="post">
<table width="345" style="margin-top:250px;">
<tr>
<th scope="row">Username</th>
<td><input type="text" name="txtusername"/></td>
</tr>
<tr>
<th scope="row">Password</th>
<td><input type="password" name="txtpassword"/></td>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" name="btnlogin" value="Login" /></th>
</tr>
<tr align="center">
<td colspan="2" style="color:#F00"><?php echo $msg; ?></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- 3. PHP PRECTICAL
3HEMANG DESAI
<?php
session_start();
?>
<?php
if (isset($_POST['logout']))
{
session_destroy();
header("location:index.php");
}
?>
<div class="header">
<div class="header_left">
<h1>Admin</h1>
</div>
<div class="header_right">
<?php
if (isset($_POST['logout']))
{
header("location: index.php");
}
?>
<form name="frmlogout" method="post">
<? Php echo “Wellcome: “. $_SESSION [‘login’]?> <input type="submit" name="logout"
value="Logout" />
</form>
</div>
</div>
<div class="maincontain_left">
<a href="addcat.php">
<div class="menu">
Add Category
</div>
</a>
</div>
<div class="footer">
<div class="footer_left">
CopyRight © By HDTC.
</div>
<div class="footer_right">
Devloped By Dax Sorathia.
Footer File (footer.php)
Menu File (menu.php)
Header File (header.php)
- 4. PHP PRECTICAL
4HEMANG DESAI
</div>
</div>
<?php
session_start();
if ($_SESSION['login']=="")
{
header("location:index.php");
}
?>
<?php
if (isset($_GET[del]))
{
include('conn.php');
$str="delete from category where id='$_GET[del]'";
mysql_query($str) or die("Not Perform");
}
?>
<?php
if (isset($_POST['update']))
{
Category File (category.php)
Footer File (footer.php)
- 5. PHP PRECTICAL
5HEMANG DESAI
include('conn.php');
$catname=$_POST['txtcategoryname'];
$imgurl=$_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
move_uploaded_file($image_tmp,"images/$imgurl");
$hid=$_POST['hid'];
$str="update category set categoryname='$catname',categoeyimage='$imgurl' where
id='$hid'";
mysql_query($str) or die("Not Perform");
header("location:addcat.php");
}
?>
<?php
if (isset($_GET[up]))
{
include('conn.php');
$str="select * from category where id='$_GET[up]'";
$res=mysql_query($str) or die("Not Perform");
while ($row=mysql_fetch_array($res))
{
$catname=$row[categoryname];
$himg=$row[categoeyimage];
$hid=$row[id];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="main">
<?php
include("header.php");
?>
<div class="maincontain">
<?php
include("menu.php");
?>
<div class="maincontain_right">
- 6. PHP PRECTICAL
6HEMANG DESAI
<form action="addcat.php" method="post" enctype="multipart/form-data"
name="form1" id="form1" style="padding-top:15px">
<table>
<tr>
<td>Cagegory Name</td>
<td>:</td>
<td><input type="text" name="txtcategoryname"
value="<?php echo $catname; ?>"/></td>
</tr>
<tr>
<td>Category Image</td>
<td>:</td>
<td><input type="file" name="image" value="<?php echo
$himg; ?>"/></td>
</tr>
<input name="hid" type="hidden" value="<?php echo $hid;?>" />
<tr align="center">
<?php
if (isset($_GET[up]))
{
echo "<td colspan='3'>"."<input type='submit'
value='Update' name='update' />"."</td>";
}
else
{
echo "<td colspan='3'>"."<input type='submit'
name='btnadd' value='Add' />"."</td>";
}
?>
<?php
if (isset($_POST['btnadd']))
{
include('conn.php');
$catname=$_POST['txtcategoryname'];
$imgurl=$_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
move_uploaded_file($image_tmp,"images/$imgurl");
$str="insert into category values
(0,'$catname','$imgurl')";
mysql_query($str) or die("Not Perform");
}
?>
</tr>
</table>
- 7. PHP PRECTICAL
7HEMANG DESAI
<table style="margin-top:5px;margin-left:5px;" border="1px"
cellpadding="3px;">
<tr>
<th>Category Name</th>
<th>Category Image</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
include('conn.php');
$str="select * from category";
$res=mysql_query($str);
while ($row=mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>".$row[categoryname]."</td>";
echo "<td>"."<img src='images/".$row[categoeyimage]."' height='40px' width='70px'>"."</td>";
echo "<td>"."<a href='addcat.php?up=$row[id]'>Edit</a>"."</td>";
echo "<td>"."<a href='addcat.php?del=$row[id]'>Delete</a>"."</td>";
echo "</tr>";
}
?>
</table>
</form>
</div>
</div>
<?php
include("footer.php");
?>
</div>
</body>
</html>
@charset "utf-8";
/* CSS Document */
*{
margin:0px;
}
.main{
background-color:#333;
}
.header{
height:60px;
CSS File (style.css)
- 8. PHP PRECTICAL
8HEMANG DESAI
width:inherit;
background-color:#FC3;
font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;
color:#333;
}
.header_left{
width:300px;
height:50px;
/*background-color:#999;*/
float:left;
padding-top:8px;
padding-left:20px;
}
.header_left h1{
text-shadow:#fff 1px 1px 1px 1px;
}
.header_center h1{
text-shadow:#fff 1px 1px 1px 1px;
}
.header_center{
width:300px;
height:50px;
/*background-color:#999;*/
float:left;
margin-left:230px;
text-align:center;
padding-top:8px;
}
.header_right{
width:100px;
height:40px;
/*background-color:#999;*/
float:right;
text-align:right;
padding-top:20px;
padding-right:20px;
}
.footer{
height:30px;
width:inherit;
background-color:#FC3;
padding-top:13px;
}
.footer_left{
height:30px;