Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

Delete function

Posted 22 Oct 2007 17:25:31
1
has voted
22 Oct 2007 17:25:31 Ashif Khan posted:
hi

i am kinda stuck with the delete function. its nt functioning. what am i doing wrong. the delete function is in the cate.php. i have provided the whole path, how to get to the cate.php through administrator.

i have highlighted the place. since iam a newby with php, iam nt sure what and how to make it work.

can anyone help me and tell me how to write that function to make it work for future reference.

thanks in advance

Ashif

index.php

continued.........

<td align="center"
class="btxorange"
bgcolor="#FFFFFF"
>
<a href="index.php" class="btxorange">Console home</a>
  
<a href="index.php?id=user" class="btxblack">User manager</a>
  
<a href="?mod=portfoliomanagement" class="btxblack">Products Management</a>
  
<a href="?mod=portfolio2management" class="btxblack">New Products Management</a>
  
<a href="?mod=newsmanagement" class="btxblack">Newsletter Management</a>
  </td>
<td align="right"
class="btxred"
>
<a href="logout.php" class="btxred">Logout</a> </td>
</tr>
<tr>
<td align="left"
class="btxorange"
bgcolor="#FFFFFF"
></td>
<td align="right"
class="btxred"
bgcolor="#FFFFFF"
> </td>
</tr>
<tr>
<td align="left"
class="btxorange"
bgcolor="#FFFFFF"
></td>
<td align="right"
class="btxred"
bgcolor="#FFFFFF"
> </td>
</tr>
<tr>
<td align="left"
class="btxorange"
bgcolor="#FFFFFF"
></td>
<td align="center"
class="btxred"
bgcolor="#FFFFFF"
> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="center">
<?php
$page = $_GET['mod'];
$page2 = $_GET['id'];
if($page == "portfoliomanagement"
{
include 'mods/portfoliomanager.php';
}
else if($page == "portfolio2management"
{
include 'mods/portfolio2manager.php';
}
else if($page == "newsmanagement"
{
include 'mods/news/hmailer.php';
}
else if($page2 == "user"

continued................


portfoliomanager.php (inside mods folder)

<table width="100%"
border="0"
cellpadding="0"
cellspacing="0"
>
<tr>
<td align="center">
<b>Products Manager</b>
</td>
</tr>
<tr>
<td align="center">
<!-- Start list of menu options -->
<br />
<table width="511"
border="0"
cellpadding="5"
cellspacing="0"
bgcolor="#DFDFFF"
>
<tr>
<td align="center" class="btxblack">
<a href="?mod=portfoliomanagement&cmd=cate" class="btxblack">Add Category</a>
 | 
<a href="?mod=portfoliomanagement&cmd=cate2" class="btxblack">Add Sub-Category</a>
 | 
<a href="?mod=portfoliomanagement&cmd=cate3" class="btxblack">Add Sub-Category 2</a>
 | 
<a href="?mod=portfoliomanagement&cmd=port" class="btxblack">Add Portfolio</a>
</td>
</tr>
</table>
<br />
<?php
$command = $_GET['cmd'];
if($command == "cate"
{
?>
<p align="center"
class="title2xgrey"
>
Add Category
</p>
<?php
include 'mods/portfolio/cate.php';
}
else if($command == "cate2"
{
?>
<p align="center"
class="title2xgrey"
>
Add Sub-Category
</p>
<?php
include 'mods/portfolio/cate2.php';
}
else if($command == "cate3"
{
?>
<p align="center"
class="title2xgrey"
>
Add Sub-Category 2
</p>
<?php
include 'mods/portfolio/cate3.php';
}
else if($command == "port"
{
?>
<p align="center"
class="title2xgrey"
>
Add Portfolio
</p>
<?php
include 'mods/portfolio/port.php';
}
else
{
?>
<p align="center"
class="title2xgrey"
>
Display all functions
</p>
<?php
}
?>
<!-- End list of menu options -->
</td>
<td align="right">
Products Management
</td>
</tr>
</table>

cate.php (inside portfolio folder)

<?php
dbConnect("xxx";
if($_GET['cmd'] == "delete"
{
$bid = $_GET['aid'];

$sqlaa = "DELETE FROM `cate` where catid = '$bid' LIMIT 1";

if(!mysql_query($sqlaa))
$msg = "Error no. bd(03)".mysql_error();

$msg .= "Category deleted";
echo "".$msg;
}
if(isset($_POST['title']))
{
//Upload file start
$uploaddir = "../images/"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, gif, jpeg, png"; // These are the allowed extensions of the files that are uploaded
$max_size = "5000000"; // 50000 is the same as 50kb
$max_height = "2000"; // This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "2000"; // This is in pixels - Leave this field empty if you don't want to upload images
$newfname = date(dmy).substr(md5(time()),0,6);
$fname = $uploaddir.$newfname.$_FILES['file']['name'];
$fnameq = $newfname.$_FILES['file']['name'];

// Check Entension
$extension = pathinfo($_FILES['file']['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension" {
$ok = "1";
}
}

// Check File Size
if ($ok == "1" {
if($_FILES['file']['size'] > $max_size)
{
print "File size is too big!";
//exit;
}

// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$fname);
$name = $_POST['title'];
$dessss = $_POST['desc'];
$banid = date(dmy).substr(md5(time()),0,24);
$sqls = "Insert into cate set
catid = '$banid',
title = '$name',
descs = '$dessss',
pic = '$fnameq'";

if(!mysql_query($sqls))
{
echo "Error occurred! Error no. bu(01)<br />".mysql_error();

}
else
{
echo "Category successfully added";
}
}
} else {
print "Incorrect file extension!";
}
// Upload file end
}
?>
<form name="addcategory"
method="post"
action="?mod=portfoliomanagement&cmd=cate"
ENCTYPE="multipart/form-data"
>
<table cellpadding="2">
<tr>
<td align="center"
colspan="2">
<h2>Add Category for Products </h2>
</td>
</tr>
<tr>
<td align="left">
Title
</td>
<td align="left">
<input type="text"
name="title"
size="50"
/>
</td>
</tr>
<tr>
<td align="left">
Description
</td>
<td align="left">
<textarea name="desc"
cols="50"
rows="5"
></textarea>
</td>
</tr>
<tr>
<td align="left">
Image
</td>
<td align="left">
<input type="file" name="file" size="30" class="btgrey">
</td>
</tr>
<tr>
<td align="left">
<input type="reset"
name="reset"
value="Clear"
/>
</td>
<td align="left">
<input type="submit"
name="submit"
value="Create Category"
/>
</td>
</tr>
</table>
</form>
<HR />
<table cellpadding="2"
cellspacing="1"
bgcolor="#cccccc">
<tr>
<td colspan="4"
align="center"
bgcolor="#ffffff"
>
<h2>Delete Category</h2>
</td>
</tr>
<?php
$grabservices = mysql_query("SELECT * FROM `cate`";
while ($grabservicesrs = mysql_fetch_array($grabservices))
{
$catid = $grabservicesrs["catid"];
$title = $grabservicesrs["title"];
$desc = $grabservicesrs["descs"];
$pic = $grabservicesrs["pic"];
?>
<tr>
<td align="left" bgcolor="#ffffff">
<img src="../images/<?php echo $pic; ?>" border="0" width="100" />
</td>
<td align="left" bgcolor="#ffffff">
<?php echo $title; ?>
</td>
<td align="left" bgcolor="#ffffff">
<?php echo $desc; ?>
</td>
<td align="left" bgcolor="#333333">
<b> &lt;a href="index.php?id=port&cmd=delete&aid=&lt;?php echo $portid; ?&gt;"&gt;Delete&lt;/a&gt; </b>
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
}
?&gt;
&lt;/table&gt;

[b]

LuV Ash

Reply to this topic