1.

Solve : PHP MySQL code for deleting items in cart doesnt work0?

Answer»

i am making php mysql code for admin side to delete ITEMS from shopping cart.Please FIND the error in the code , cause i cant find it.

Delete product is the place where i show the items selected by productid as options for admin to choose to delete.
Delete product works ,whose screen short can as well be shown in the document file.Delete product then submits the CHOSEN selected item to delete product1.

Delete product 1 is where i am trying to delete the option as chosen by admin via delete product.I tried my best to remove error in the delete product 1 but couldn't solve it , i will be grateful if you did.Please remove the errors in delete product document file.

1)Delete product code working showing form to choose option for deletion as shown in the image
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml">


Delete Product Details


function clearText(field)
{
if (field.defaultValue == field.value) field.value = '';
ELSE if (field.value == '') field.value = field.defaultValue;
}








include 'header.php';
?>







Delete Product Details



if(isset($_SESSION['uname']))
{
include 'dbconnect.php';
echo "Welcome ".$_SESSION['uname'].",";
?>
if($_SESSION['utype']=='A' )
{
?>


Product Name
include 'dbconnect.php';

$sql="select * from product";
$res = $dbconn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$res->execute();
$disp="";
while($RS = $res->fetch())
{
$disp.="".$rs['name']."";
}
echo $disp;
?>
 


}
else
header('location: adminlogin.php');
}
else
header('location: adminlogin.php');
?>








include 'footer.php';
?>









2) Delete product 1 doesn’t work as there is some error in the code. Please remove the errors please. Here is the not working code of delete product 1. :
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml">


Delete Product Details


function clearText(field)
{
if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;
}









include 'header.php';
?>







Delete Product Details



if(isset($_SESSION['uname']))
{
include 'dbconnect.php';
echo "Welcome ".$_SESSION['uname'].",";
?>
if($_SESSION['utype']=='A' )
{
?>

if(isset($_POST['txtPName']))
{

include 'dbconnect.php';
$txtPName=$_POST['txtPName'];
try
{
$sql="delete from product where idProduct=:idProduct";
$q = $dbconn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$q->execute(array(':idProduct'=>$txtPName));
echo "

Product ID : $txtPName one quantity deleted";



}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
else
header('location:deleteproduct.php');
}
else
header('location: adminlogin.php');
}
else
header('location: adminlogin.php');
?>









include 'footer.php';
?>






[recovering disk space, attachment deleted by admin]


Discussion

No Comment Found