I am creating a simple blog but I don't manage to make the delete button work. I think I am missing out on the button? I am well aware of SQL INJECTION and PREPARED STATEMENTS. I will be dealing with them later. There are no errors with connection. My delete query is in a function deleteArticles() on this page: articles.sql.php
// DELETE
function deleteArticle($c){
$item = $_GET['item'];
$qryDeleteArt = 'DELETE FROM articles
WHERE artID = \''.$item.'\'';
if (!mysqli_query($c,$qryDeleteArt))
{
die('Error: ' . mysqli_error($c));
} echo 'success';
}
// CONTROLER //
switch( $action ){
case 'insert' :
$process = insertArticle($conn);
if( $process == 'ok' )
header( 'location:index.php?page=home' );
else
$page = 'articleform';
break;
case 'update' :
$process = updateArticle($_GET[ 'item' ]);
if( $process == 'ok' )
header( 'location:index.php?page=home' );
else
$page = 'articleform';
break;
case 'delete' :
$process = deleteArticle( $conn, $_GET[ 'item' ] );
if( $process == 'ok' )
header( 'location:index.php?page=home' );
break;
}
?>
Form is on this page: home.php
<div class="article">
<h3>
<?php
while($rows = mysqli_fetch_array($rArticles)){
?>
<a href="index.php?page=articleform&article="><?php echo $rows['artTitre']; ?></a>
<span><a class="btn" href="index.php?page=articles&action=delete&item=">supprimer</a></span>
</h3>
<p><em><?php echo $rows['artDate']; ?> - <?php echo $rows['artAuteur']; ?></em></hp>
<p><?php echo $rows['artContenu']; ?></p>