Hello. I have a problem with deleting promo code value from the database.
I have form created with php which sends(or must send) info from the form to the dcodes_action.php.
I need to send $new_row to dcodes_action.php but when I echoing this later on the dcodes_action.php page I got only “submit” in the place of $new_row value.
This is my first file:
echo '<div class="table">';
foreach ($row_arr as $new_row) {
echo "<table id='table'>";
echo "<tr>";
echo "<form action='../admin/dcodes_action.php' id='form' method='get'>
<td>
<input class='delete_button' name='todelete' type='submit'><span id='code'>".$new_row."</span></input>
</td>";
echo "</tr>";
echo "</table>";
}
echo "<input type='submit' value='Delete'>
</form></div>";
echo "<form action='../admin/dcodes_action.php' id='new_code'>
<input id='new_code_textfield' type='text' name='newcode' placeholder='Enter new code'>
<input id='new_code_submit' type='submit' value='Submit'>
</form>";
$conn->close();
?>
And I have a table of all the *promocodes but the problem is in transfering to the database.
My second destination file looks like:
if($code_to_delete = $_GET['todelete']){
echo $code_to_delete.'code to delete<br/>';
$sql_code_delete = "DELETE FROM dcodes WHERE value = ('" .$code_to_delete. "')";
if ($conn->query($sql_code_delete ) === TRUE) {
echo "<br/>deleting code";
} else {
echo "Wrong";
}
}