I have got problems to Implement my own Module, wich I want to develop.
My Steps:
in /admin/includes/application_top.php + define('FILENAME_MYMODULE', 'test_mymodule.php');
/lang/german/admin/gm_german.php + define('BOX_MYMODULE', 'MyModule');
/lang/german/sections/_samples/admin_menu.lang.inc.php + 'BOX_MYMODULE' => 'MyModule',
INSERT INTO ``gm_lang_files_content`` VALUES('', 246, 'BOX_MYMODULE', 'MyModule');
/system/conf/AdminMenu/gambio_menu.xml + <menuitem sort="10" link="FILENAME_MYMODULE" title="{$txt.BOX_MYMODULE}" />
Now my Problem is, when I clear the cache and reload, I didn't see my menu option.
If I change test_mymodule.php in gm_ebay.php or somethink else it will work.
Why it dosent work with my file?
I would be extremely grateful for your help
i found the solution, i think some newbie like me in gambio search it to.
last point insert in database
ALTER TABLE admin_access ADD myfile INT( 1 ) NOT NULL DEFAULT '0';
and update it to 1 for true
Updated solution to stay updateable:
Menu entry:
/user_classes/conf/admin_menu/menu_mymodule.xml
<?xml version="1.0"?>
<!-- {load_language_text section="admin_menu"} -->
<admin_menu>
<menugroup id="BOX_HEADING_IMPORT_EXPORT">
<menuitem sort="10" link="mymodule.php" link_param="your=param" title="MyModule" />
</menugroup>
</admin_menu>
Create /admin/includes/modules/mymodule/css/mymodule_backend.css
Create /admin/includes/modules/mymodule/index.php
<?php
$string = '<td class="boxCenter" width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading" style="background-image: url(images/icons/amicicard_30.png);float:left;"> MyModule</td>
<td class="pageHeading" align="right"><img src="images/pixel_trans.gif" border="0" alt="" width="HEADING_IMAGE_WIDTH" height="HEADING_IMAGE_HEIGHT"></td>
</tr>
</table>
<span class="main">
';
echo $string;
echo "Do your work here like that.<br>";
echo "You can include classes etc. in here and use echo as output.";
echo '</div>';
Create /admin/mymodule.php
<?php
$version = phpversion();
$majorVersion = explode('.', $version);
$majorVersion = intval($majorVersion[0]);
if ($majorVersion < 5)
{
return;
}
require('includes/application_top.php');
$isPopup = isset($_GET['popup']) ? true : false;
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/modules/mymodule/css/mymodule_backend.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php
if (!$isPopup)
{
//include header:
require(DIR_WS_INCLUDES . 'header.php');
//include body:
echo '<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td class="columnLeft2" width="'.BOX_WIDTH.'" valign="top"><table border="0" width="'.BOX_WIDTH.'" cellspacing="1" cellpadding="1" class="columnLeft">';
//include left navigation:
require(DIR_WS_INCLUDES . 'column_left.php');
echo '</table></td>';
}
else
{
//include body:
echo '<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td class="columnLeft2" width="100%" valign="top"><table border="0" width="0" cellspacing="1" cellpadding="1" class="columnLeft">';
}
require_once('./includes/modules/mymodule/index.php');
echo '</tr></table>';
if (!$isPopup)
{
//footer:
require(DIR_WS_INCLUDES . 'footer.php');
}
echo '<br>
</body>
</html>';
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
Update your Database like mentioned by user unfair
last point insert in database ALTER TABLE admin_access ADD myfile INT( 1 ) NOT NULL DEFAULT '0';
and update it to 1 for true
Thats it.
Result Image
Related
I have added images and the corresponding links to the database and viewed on index page, problem is when i click the images it goes to the present page, it does not open corresponding links related to images. But same is working fine in marquee.
code for adding images and links is
<?php
include_once("../init.php");
validation_check($_SESSION['UID'], SITE_HOME_ADMIN);
$msg='';
if(isset($_POST['save']))
{
$upDir ='../'.VIDEO;
$videourl = $_POST['videourl'];
$insertSql =("INSERT INTO videonews (videourl)
VALUES ('$videourl')");
$insertSql="INSERT INTO ".VIDEONEWS." SET
`adv_url` = '".realStrip($_POST['adv_url'])."'";
$query = mysql_query($insertSql);
$adv_id = mysql_insert_id();
$adv = '';
if($_FILES["adv"]['name']!= ''){
$fileData = pathinfo(basename($_FILES["adv"]["name"]));
$adv = $adv_id . '_adv.' . $fileData ['extension'];
move_uploaded_file($_FILES["adv"]["tmp_name"], $upDir . $adv);
}
$upSql="UPDATE ".VIDEONEWS." SET `adv` = '".$adv."' WHERE id = '$adv_id'";
$query = mysql_query($upSql);
$msg = '<h3>Record Saved</h3>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Video News</title>
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
<script type="text/javascript">
</script>
</head>
<body>
07/25/2014
<div class="fixx">
<?php include('header.php');?>
</div>
<div class="tabl">
<table width="700" border="0">
<tr>
<td><form action="news1.php" method="post" enctype="multipart/form-data">
<table width="900" border="1" cellpadding="10">
<tr>
<td colspan="2"><h3> ADD Files To Video News | EDIT </h3></td>
</tr>
<tr>
<td colspan="2"><?php echo $msg;?></td>
</tr>
<tr>
<td><input type="file" name="adv" id="adv" /><input type="text" placeholder="URL" name="adv_url" id="adv_url" size="50" /></td></tr>
</tr>
<tr>
<td>Video Link <input type="text" name="videourl" id="videourl" size="100" /></td></tr>
<tr> <td><input type="submit" name="save" id="save" value="Submit" /></td></tr>
</table>
</form></td>
</tr>
</table>
</div>
</body>
</html>
Retrieving file code is
<?php
validation_check($_SESSION['UID'], SITE_HOME_ADMIN);
$msg='';
$adDir ='./'.VIDEO;
$qr = mysql_query("select * from ".VIDEONEWS) or die('Error in connection');
while($rs = mysql_fetch_array($qr))
{
$adv = '';
if($rs['adv']!='') {
$adv = '<img src="'.$adDir.$rs['adv'].'" style="width:250px; height:150px" > ';
}
$image = $adv;
$msg .='<tr>
<tr>'.$image.'</tr>
</tr>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Videonews Lists</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
</head>
<body>
<div class="tabl">
<table width="100%" border="0" align="center" class="main">
<td>
<table width="95%" border="1" align="center" cellpadding="10">
<?php echo $msg;?>
</table>
</td></tr></table>
</body>
</html>
Retrieving file is included in index.php to show all images in a frame.
Marquee code in index page which is working fine is
<div class="ads-242x90 right">
<strong>VIDEO NEWS</strong>
<marquee direction="up" scrollamount="2" onmouseover="this.stop();" onmouseout="this.start();">
<div align="left" >
<span style="text-transform:uppercase;">
<?
$qryAdv = mysql_query("SELECT * FROM ".VIDEONEWS." WHERE 1");
if(mysql_num_rows($qryAdv) > 0)
{
while($adv = mysql_fetch_assoc($qryAdv))
{
?>
<img src="<?=VIDEO.$adv['adv']?>" width="98%" height="90" alt=""> <br />
<?
}
} else { echo 'NO ADDS FOUND!!!'; }
?>
</marquee>
First thing you should do is to protect yourself from SQL injection, read about it.
I think your problem lies here:
$adv = ''; ///you set $adv equal to empty string
if($rs['adv']!='') { //VVVV here you try to use your empty string
$adv = '<img src="'.$adDir.$rs['adv'].'" style="width:250px; height:150px" > ';
}
I believe it should be
//VVVVVV
$adv = '<img src="'.$adDir.$rs['adv'].'" style="width:250px; height:150px" > ';
I am getting image, title and external URL from database, and display it on my page, code is working well, But i don't want to display URL, I want when I click image or title it should go direct to that URL in new window. My Code is
<?php
include_once("init.php");
$msg='';
$adDir ='./'.EDITORIALNEWS;
$qr = mysql_query("select * from " .enews) or die('Error in connection');
while($rs = mysql_fetch_array($qr))
{
$adv = '';
if($rs['adv']!='') {
$adv = '<img src="'.$adDir.$rs['adv'].'" style="width:60px; height:60px" > ';
}
$image = $adv;
$msg .='<tr>
<td>'.$image.'</td>
<td>'.$rs['title'].'</td>
<td>'.$rs['adv_url'].'</td>
</tr>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Editorialt News Lists</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
</head>
<body>
<div class="tabl">
<table width="95%" border="1" align="center" cellpadding="10">
<tr>
<td width="35%"><strong>File</strong></td>
<td width="30%"><strong>Title</strong></td>
<td width="30%"><strong>Link</strong></td>
</tr>
<?php echo $msg;?>
</table>
</body>
</html>
Image, Title, URL are adv, title and adv_url respectively.
I think the line added should be like
<img src="<?=VIDEO.$adv['adv']?>" width="98%" height="90" alt="">
but how and where to use it don't know. Being a student I have keen interest in learning PHP through projects.
You can do it like as follows:
Replace the following line of your code with my code:
if($rs['adv']!='') {
$adv = '<img src="'.$adDir.$rs['adv'].'" style="width:60px; height:60px" > ';
}
//My code
if($rs['adv']!='') {
$adv = '<img src="'.$adDir.$rs['adv'].'" style="width:60px; height:60px" > ';
}
I had it working and at some point broke it yesterday and can't figure it out.
I am generating an html file from a form input.
I call a function if data is posted to the page, but the "foreach" loops don't run the first time the form is submitted...and it's 1 asset shy afterwards, if you upload 3 images, it'll show 2 on the generated page...
function AddClientDB($client, $pth, $project){
mysql_connect('localhost', 'dbname', 'pw'); //connect to db
mysql_select_db('tablename'); //select file
$indx = $project.".html";
$sql="INSERT INTO Clients VALUES (NULL,'$client', '$project', 'http://webpage.net/','$pth','$indx')";
mysql_query($sql) or DIE("Problems with the query:<pre>$sql</pre>" . mysql_error());
//Create client folder
if (!file_exists('uploads/'.$client)) {
mkdir('uploads/'.$client, 0777, true);
echo "Created Folder for Client: ". $_GET['client']. "<br />";
}
//Make project folder under client
if (!file_exists('uploads/'.$client. '/'. $project)) {
mkdir('uploads/'.$client.'/'.$project, 0777, true);
}
$sql="INSERT INTO Projects VALUES (NULL,'$project', '$client',0,0,'$pth')";
mysql_query($sql) or DIE("Problems with the query:<pre>$sql</pre>" . mysql_error());
$myFile = 'uploads/'.$client.'/'.$project . '/' . $project.".html";
$fh = fopen($myFile, 'w') or die("can't open file");
//Top part of html page to make
$stringDataA = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Title</title>
<link rel="stylesheet" type="text/css" href="http://pixelfirereview.net/styles.css">
<script type="text/javascript">
function popDate(){
var dt=new Date();
document.getElementById("dat").innerHTML=dt;
}
</script>
</head>
<body onload="popDate();">
<div align="center">
<table width="960" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="960" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="480"></td>
<td width="480"><img src="http://www.pixelfireinc.com/pfp2011/wp-content/uploads/2011/04/PixelfireLogoTopSM1.png" width="340" height="72" border="0" align="right" /></td>
</tr></table></td></tr><tr><td> </td></tr><tr><td>
<table width="960" border="0" cellspacing="0" cellpadding="0"><tr>
<td><div align="center"</div></td></tr><tr>
<td><div align="center">';
//Foreach valid file in the project folder, add it to our $content variable as a string.
//For some reason, the foreach loops only run the second time the form is submitted...if you hit f5 and continue through the warning about resubmitting data, it then fires the code in the foreach loops....
foreach (glob($pth. '*.jpg') as $filename2) {
echo "<br />filename2: ". $filename2. "<br />";
// echo "<br />$filename size " . filesize($filename2) . "<br />";
$content = $content . '<span class="m_title">'.$filename2.'</span><br /><p><img src="http://pixelfirereview.net/'.$filename2.'" /><br /><br /><img src="http://pixelfire.net/clients/images/btn_download.png" width="235" height="50" border="0" align="right" /></p><br />';
}
foreach (glob($pth. '*.png') as $filename3) {
echo "<br />filename3: ". $filename3."<br />";
echo "<br />\n$filename size " . filesize($filename3) . "<br />";
$content = $content . '<br /><span class="m_title"><!-- InstanceBeginEditable name="Project Title" -->'.$filename3.'</span><img src="http://pixelfirereview.net/'.$filename3.'" />
<br /><br /><p><img src="http://pixelfire.net/clients/images/btn_download.png" width="235" height="50" border="0" align="right" /></p><br />';
}
foreach (glob($pth. '*.mp4') as $filename4) {
echo "<br />filename4: ". $filename4."<br />";
// echo "<br />\n$filename size " . filesize($filename4) . "<br />";
$content= $content. '<br /><span class="m_title">'.$filename4.'</span><div id="mediaplayer'.$filename4.'"></div><script type="text/javascript" src="http://www.pixelfire.net/clients/jwplayer.js"></script><script type="text/javascript">
jwplayer("mediaplayer'.$filename4.'").setup({
flashplayer: "http://www.pixelfire.net/clients/player.swf",
file: "http://pixelfirereview.net/'.$filename4.'",
width: "960",
height: "565",
autoplay: "false",
image: "http://www.pixelfire.net/clients/images/VideoPreview.jpg",
repeat: "always",
controlbar: "bottom",
});
</script><br />
<p><img src="http://pixelfire.net/clients/images/btn_download.png" width="235" height="50" border="0" align="right" /></p><br />';
}
foreach (glob($pth. '*.wav') as $filename5) {
$content = $content . '<span class="m_title">'.$filename5.'</span><div id="mediaplayer'.$filename5.'"></div> <script type="text/javascript" src="http://www.pixelfire.net/clients/jwplayer.js"></script> <br /><script type="text/javascript">
jwplayer("mediaplayer'.$filename5.'").setup({
flashplayer: "http://www.pixelfire.net/clients/player.swf",
file: "http://pixelfirereview.net/'.$filename5.'",
width: "960",
height: "565",
autoplay: "false",
image: "http://www.pixelfire.net/clients/images/VideoPreview.jpg",
repeat: "always",
controlbar: "bottom",
});
</script><br />
<p><img src="http://pixelfire.net/clients/images/btn_download.png" width="235" height="50" border="0" align="right" /></p>';
}
//Create the lower half of the html page
$stringDataB= '</div></td></tr><tr><td height="20"> </td></tr><tr><td><table width="960" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="620" valign="top"><table width="550" border="0" cellspacing="0" cellpadding="1"><tr>
<td width="125" class="m_main"><div align="right">Last Modified:</div></td>
<td width="400"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
<div id="dat" style="margin-top:80px;background:#333333;padding:.5em;" align="left" class="m_main_alt"></div></div></td></tr></table></td></tr></table></td><td width="350" valign="top">
<table width="350" border="0" cellspacing="1" cellpadding="0"><tr>
<td></td>
</tr></table></td></tr></table></td></tr><tr><td height="100"></td></tr></table></td></tr><tr><td></td></tr><tr><td>
<div align="center" class="footer">© 2013 PixelFire Productions<br /> (425) 917-1400 </div></td> </tr> </table></div></body></html>';
//Put the pieces together, top html, content, bottom html.
$stringData = ''.$stringDataA . $content . $stringDataB.'';
fwrite($fh, $stringData);
}
It creates the HTML page and all, but the first time it runs $content is empty....if you press F5 after submitting the form and press Continue at the message about resubmitting data, it then runs the code in the foreach loops and $content will contain a string that's put in between the top and bottom halves of the html.......
Any ideas why that might be???
Got it working by splitting it into a couple functions and forcing the order.
Hi i've managed to make some sort of a comment box that relies on the use of a mysql database and php coding. I'm able to run the comment box by opening its index.php file on my server but when i try adding it to a html page by using a simple include_once php code
it doesn't seem to work.
please excuse me if I sound stupid but this is my first time using php.
here is the code i've been trying to use.
<?php
include_once("../connect.php");
$commenting_form = '<form action="addcomment.php" method="post">
<table width="310" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><strong>Add Comment:</strong></td>
</tr>
<tr>
<td width="105">Title</td>
<td width="205"><input type="text" name="msg_title" id="msg_title" style="width:200px;" /></td>
</tr>
<tr>
<td colspan="2"><textarea name="msg_message" id="msg_message" style="width:100%;height:200px;font-family:Courier New">Message</textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Add Comment" name="msg_submit" id="msg_submit" /></td>
</tr>
</table>
</form>';
$get_comments = mysql_query("SELECT * FROM comments");
$comments_count = mysql_num_rows($get_comments);
if ($comments_count>0)
{
while ($com = mysql_fetch_array($get_comments))
{
$id = $com['id'];
$title = $com['text'];
$message = $com['message'];
$comment .= '<strong>'.$title.'</strong><br />'.$message.'<hr />';
}
$comment .= $commenting_form;
$page_title = $comments_count.' Comments';
}
else
{
$comment = 'There are no comments at the moment.<br />'.$commenting_form;
$page_title = 'No Comments';
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $page_title; ?></title>
</head>
<body>
<?php
echo $comment;
?>
</body>
</html>
Try this:
include "../connect.php";
NOTE: make sure you put the right path of connect.php
This is a page where users can edit their uploaded images. There is a checkbox near each image. I want to delete the selected images after user clicks the "delete selected images" button (each checkbox contains the image name as value). How can I do that?
<?php
session_start();
//////////////if user already logged in go to login.php/////////
if (isset($_SESSION['email'] )&& isset($_SESSION['password'] ))
{
} else{header( "Location: login.php" ); }
include('includes/config.php');
if (isset($_POST['esubmit']) ){
$checkbox=$_POST['delete'];
echo $checkbox;
}//main one
if (isset($_POST['esubmit']) ){
} else { $clickeditid=$_GET["id"];
$_SESSION['eid']= $clickeditid ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/css.css" rel="stylesheet" type="text/css" />
<style rel="stylesheet" type="text/css">
input {
border-style: solid;
border-color: #000000;
border-width: 1px;
background-color: #ffffff;
}
</style>
<script src="js/css_browser_selector.js" type="text/javascript"></script>
</head>
<body>
<?php
include('includes/topmenu.php');//top menu
echo '<br />';
include('includes/usermenu.php');///bcoz of this menu error occurs
////////////////////
include('includes/edit_img_menu.php');
?>
<form id="form1" name="form1" method="post" action="editimg.php?id=<?php echo $_SESSION['eid'];?>">
<table align="center" width="70%" cellspacing="0">
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"><?php
$imgcheck=mysql_query("
SELECT *
FROM `images`
WHERE `deal_id` =$_SESSION[eid]
LIMIT 0 , 30
");
$numimgcheck=mysql_num_rows($imgcheck);
if($numimgcheck==0){echo '<span style=color:#ff0000; >No pictures uploaded</span>';}
while ($rowimg2= mysql_fetch_array($imgcheck)){
$imgname=$rowimg2['name'];
{
echo ' <a href="users/'.$_SESSION['userid'].'/images/'.$imgname.'" rel="lightbox[slide]" caption=".">';
}
{ echo '<img src="users/'.$_SESSION['userid'].'/images/thumbs/'.$imgname.'" border="0" />';}
{ echo '</a><input type="checkbox" name="delete" id="delete" value="'.$imgname.'">
';}
}
?></td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#95F8FD"><input name="esubmit" type="submit" class="red" id="esubmit" value="Delete selected images" /></td>
</tr>
<tr>
<td width="89"> </td>
<td colspan="2"> </td>
</tr>
</table>
</form>
</body>
</html>
You have to create a form to submit the data of the checked checkboxes and treate the submited result with the php code : if you want to put the php code on the same page, you can check if there is any data in the POST vars and create a SQL Query to delete the corresponding pictures.
You can find a very well documented tutorial here : http://sharemyphp.wordpress.com/2009/12/21/ajax-jquery-php-multiple-delete-item-with-check-box/
Regards,
Max
I use the below code to delete images in my admin panel. I saved the file as deletephoto.php. Note that this script works without login. You need to make some changes to fit your use case
<form method="post" action="deletepho.php">
<center>
<input type="submit" value="Delete" name="Delete">
</center>
<?php
\\lets assign the folder name in $title
\\You can assign any name
$title= "test";
\*$directory corresponds to whole path. Edit to your preference. (i assume u store your
images in directory named "images") */
$directory = "$title/images";
\\The array specifies the format of the files
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;
$dir_handle = #opendir($directory) or die("There is an error with your image directory!");
while ($file = readdir($dir_handle))
{
if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = implode('.',$file_parts);
$title = htmlspecialchars($title);
$nomargin='';
if(in_array($ext,$allowed_types))
{
if(($i+1)%4==0)
$nomargin='nomargin';
echo'
<div id="picture">
<img src="'.$directory.'/'.$file.'" width="150" height="150"><br>
Select <input type="checkbox" value="'.$directory.'/'.$file.'" name="imgfile[]">
\* I specified input name as an array . So that we can store in an array and delete it.*/
</div>';
}
$i++;
}
closedir($dir_handle);
\\Now we have the list of images within form elements
?>
</form>
Now here is the actual code to delete the photos. I saved it as deletepho.php.
$file = $_REQUEST['imgfile'];
$num_files=count($file);
for($i=0;$i<$num_files;$i++)
{
unlink ("$file[$i]");
}
echo "Images successfully deleted.Go <a href='deletephoto.php'>back</a>";