Jump to content

Won't delete from database.


ryeman98

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');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.