Jump to content

Click and Delete


LouisX

Recommended Posts

Hi, I have some question to ask about this code. I have a images path store into config.ini. I can display the images only the problem is I want to click and delete the image after confirm.

 

Please help...

 

index.php

$file = $_SERVER['DOCUMENT_ROOT'] . "/uploads/config.ini";
$contents = file($file);
$string = implode($contents);

$lines = file($file);

print "<table border=1><tr>";

foreach ($lines as $line_num => $line) {

echo "
<td WIDTH=220 HEIGHT=220>
<a title=\"Delete File\" href=\"javascript:;\" onClick=\"cf=confirm('Are you sure you want to delete?');if (cf)window.location='functions.php?action=del&file=" . htmlspecialchars($line) . "'; return false;\">
<IMG SRC=" . htmlspecialchars($line) . " WIDTH=\" \" HEIGHT=\" \" BORDER=\"0\"  TITLE=\" " . htmlspecialchars($line) . " \" \/>
</a><br />
</td>";
}

print "</tr></table>";

 

functions.php

$action = $_GET['action'];

switch($action) {	

case 'del':
unlink($_GET['file']);


break ;
}

Link to comment
https://forums.phpfreaks.com/topic/174194-click-and-delete/
Share on other sites

There are other possibilities but, AJAX is actually the easiest option. That is if you still don't want the user to be redirected to another page?

 

actually i just need someone to help on my code, is that a problem? i trying to click and delete the images but it seem doesn't show the prompt message. maybe without ajax or someone can help?

Link to comment
https://forums.phpfreaks.com/topic/174194-click-and-delete/#findComment-918805
Share on other sites

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.