deleting a file with a confirmation pop up

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

deleting a file with a confirmation pop up

Post by wesnoel »

ok so I know how to delete a file from a dir.

...but what if I make a mistake and delete the wrong file?

Is there way to have a pop up ie. javaScript or something like that, that says are you sure you want to delete this file.

The delete script I am using is:

Code: Select all

<?php
if(isset($del)){
unlink("$del");
}
?>
and the link to that is:

Code: Select all

&lt;a href="index.php?del=files/$file" target="_self"&gt;DELETE&lt;/a&gt;

How can I add that confirmation pop up?

Any help would be apreciated.

TIA,


Wes
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

yes.

Code: Select all

onClick="alert('Are you sute you want to continue?');"
added to the link will then pop up an alert before going through
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Post by wesnoel »

thank you for that idea but I couldn't get that to work.

Back to the drawing bord.

:D

Wes/
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

try this, you need to use confirm instead of alert

Code: Select all

<a href="index.php?del=files/$file" target="_self" onClick="confirm('Are you sure you want to continue?');">DELETE</a>
Mark
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

that right. alert doesn't give you a way to back out.
Post Reply