echo "<td><a 
        onclick='return confirm("Do you want to delete?")'

I am not being able to correct it...

Recommended Answers

All 4 Replies

Member Avatar
echo "<td><a href='delete.php?user_id={$row['user_id']}' onclick='return confirm(\"Do you want to delete?\")'>DELETE</a></td>";

try something like this..

echo "<td><a href=delete.php?user_id=$row[user_id] onclick=return confirm('Do you want to delete?')> DELETE</a></td>";

not hundred percent sure..i just get it on top of my head..nothing wrong with trying:D

$therow = $row['user_id'];

echo '<td><a
    onclick="return confirm("Do you want to delete?")">DELETE</a></td>';
Member Avatar

I don't think any of these solutions will work for you. This might.

echo "<a href=\"#\" onclick=\"if(confirm('Do you want to delete?'))window.location='delete.php?user_id={$row['user_id']}';\">DELETE</a>

However, you should ensure that you have sufficient protection in delete.php so that ONLY you or a trusted user with sufficient rights can delete users (I assume from the DB).

I usually provide a 'defence in depth' measure of assigning a confirmation hash to go along with the id no, which is checked in delete.php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.