LouisX Posted September 14, 2009 Share Posted September 14, 2009 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 ; } Quote Link to comment Share on other sites More sharing options...
Adam Posted September 14, 2009 Share Posted September 14, 2009 You mean you want to perform this in the background, without the page redirecting? If so, sounds like you want to look into "AJAX". Quote Link to comment Share on other sites More sharing options...
LouisX Posted September 14, 2009 Author Share Posted September 14, 2009 You mean you want to perform this in the background, without the page redirecting? If so, sounds like you want to look into "AJAX". yeah, want it do at the backgound... can it be done?? or with a page redirect, how? thanks for your reply... Quote Link to comment Share on other sites More sharing options...
Adam Posted September 14, 2009 Share Posted September 14, 2009 If so, sounds like you want to look into "AJAX". ... Read up on AJAX. Quote Link to comment Share on other sites More sharing options...
LouisX Posted September 15, 2009 Author Share Posted September 15, 2009 If so, sounds like you want to look into "AJAX". ... Read up on AJAX. Hi, I try to use ajax but seem no very comfortable. can i use other way? Quote Link to comment Share on other sites More sharing options...
Adam Posted September 15, 2009 Share Posted September 15, 2009 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? Quote Link to comment Share on other sites More sharing options...
LouisX Posted September 15, 2009 Author Share Posted September 15, 2009 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.