Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Seeing your code, I spotted an error:</p> <pre><code>&lt;div id="dir_del"&gt; &lt;form name="album_del_form" id="album_del_form" method="post" action="1a.php"&gt; &lt;input type="image" src="images/delete.gif" name="al_dell" id="al_dell" value="&lt;? echo $file; ?&gt;"/&gt;&lt;? echo $file; ?&gt; &lt;input type="hidden" id="al_del" value="&lt;? echo $file; ?&gt;" /&gt;&lt;/form&gt; &lt;/div&gt; </code></pre> <p>Given you write this code inside a <code>while</code> loop, there will be more than one elements like this repeated. There will be more than one form with <code>id='album_del_form'</code> and <code>div</code> with <code>id="dir_del"</code>. Please change the way you display the form.</p> <p>If I can suggest, build it like this:</p> <pre><code>&lt;form name="album_del_form" id="album_del_form" method="post" action="1a.php"&gt; &lt;?php //... while (($file = readdir($cur_dir)) !== false) { ?&gt; &lt;?php if ( $file != "." &amp;&amp; $file != ".." &amp;&amp; is_dir($file) ) { $i_count = $i_count + 1; ?&gt; &lt;div id="dir_del_&lt;?php echo $i_count; ?&gt;"&gt; &lt;input type="image" src="images/delete.gif" name="al_del[]" id="al_dell_&lt;?php echo $i_count; ?&gt;" value="delete &lt;?php echo $file; ?&gt;"/&gt; &lt;?php echo $file; ?&gt; &lt;/div&gt; &lt;?php } } ?&gt; &lt;/form&gt; &lt;div id="dir_del"&gt;&lt;/div&gt; </code></pre> <p>And inside <code>1a.php</code>, access `al_dell using array:</p> <pre><code>if ( isset($_POST['al_del']) &amp;&amp; is_array($_POST['al_del']) ) { foreach ( $_POST['al_del'] as $dir ) { rmdir($dir_path.'/'.$dir); echo 'album deleted'; } } </code></pre> <p>Write a code with consistent indentation will help you spot the bug and fix it quickly. Make it into habit ;)</p> <p>Also, use firebug to see the error in your page. Make sure that jQuery and jQuery form is loaded, and the form is being submitted via jQuery form plugins, not using normal form submit. form submitted via jQuery form will not cause page reload or loading <code>1a.php</code>, and the request and response will appear in Firebug console and network tab (if you activate it).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload