Jump to content

Recommended Posts

Hi there, I hope you're having a good day :P

 

Whenever I click the submit image, that is supposed to delete it, but it doesn't. delete it from the database. Here's the code:

Main page

<?php
<form action=\"http://php.sunnyneo.com/DeleteProject.php\" method=\"post\"><input type=\"hidden\" name=\"id\" value\"".$row['id']."\"><input type=\"image\" src=\"http://php.sunnyneo.com/images/cancel_f2.png\" alt=\"Delete\"></form>
?>

 

Delete page

<?php
$id = $_POST['id'];

$delete = mysql_query("DELETE FROM `projects` WHERE id='$id'")
or die(mysql_error());

header('Location: http://somesite.com/project.php');
?>

Link to comment
https://forums.phpfreaks.com/topic/56596-wont-delete-from-database/
Share on other sites

First off, do just:

 

<?php
$bla = mysql_query("DELETE FROM projects WHERE id = '$id'")
?>

 

But you should probably do this instead for this first page:

 

<?php
<a href="http://php.sunnyneo.com/DeleteProject.php?id=".$row['id']."" /><img src="" border="0" /></a>

//then use the $_GET['id'] method..
?>

Still won't delete and I changed a few pages:

 

<?php
require($_ENV['SITE_HTMLROOT']."/include/dbconnect_class.php");
$db = new DB;

$id = $_POST['id'];

$delete = mysql_query("DELETE FROM `projects` WHERE id = '$id'");

header('Location: http://somesite.com/project.php');
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.