Click here to Skip to main content
15,889,861 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionRESOURCE Role Pin
Member 1072866713-Apr-15 15:38
Member 1072866713-Apr-15 15:38 
Questionwhy the sign-in is slow?! Pin
Jassim Rahma23-Mar-15 9:58
Jassim Rahma23-Mar-15 9:58 
QuestionSQL Pin
Member 1072866722-Mar-15 20:30
Member 1072866722-Mar-15 20:30 
QuestionRe: SQL Pin
Richard MacCutchan22-Mar-15 22:01
mveRichard MacCutchan22-Mar-15 22:01 
AnswerRe: SQL Pin
syed shanu22-Mar-15 22:28
mvasyed shanu22-Mar-15 22:28 
QuestionHow to expire a session? Pin
Jassim Rahma20-Mar-15 8:14
Jassim Rahma20-Mar-15 8:14 
AnswerRe: How to expire a session? Pin
speda127-Sep-15 13:15
speda127-Sep-15 13:15 
QuestionHow to Delete file when Selected from Dropdown List Pin
Member 1150850510-Mar-15 20:09
Member 1150850510-Mar-15 20:09 
I have a dropdown list populated with files pulled from a directory using the PHP listed below and am trying to figure out how I can delete them using a delete button in the form when they're selected.

PHP
<input type="hidden" name="Action" value="EDIT" /><input type="hidden" name="Selection"  id="Selection" value="-1"><div>Below is the list of your saved codes. To edit your codes, select it from the list.</div>
<select size="1" name="CodeList" id="CodeList">
<?php
   $directory = $directory = 'users/' . $_SESSION['username'];
   $filesContents = Array();
   $files = scandir( $directory ) ;

   foreach( $files as $file )
  {
   if ( ! is_dir( $file ) )
  {
   $filesContents[$file] = file_get_contents($directory , $file);
  echo "<option>" . $file . "</option>";
  }
   }
   ?>
   </select>


delete php script.

PHP
<?php
   session_start();
    $directory = $directory = $_SERVER['DOCUMENT_ROOT'] . '/users/' . $_SESSION['username'];
    $file_to_delete = $_POST['CodeList'];
    if ( unlink ($directory.'/'.$file_to_delete) ) {
      echo $file_to_delete . " deleted.";
   } else {
echo "Error.";
}
?>


when I try and save I get the Warning: unlink(/myhome/root/public_html/users/Addiction/) [function.unlink]: No such file or directory in /home/revo/public_html/evo/avdeleteprocess.php on line 5 Error.

So its found the right folder, just not finding the file from the dropdown list selection.

Also edited to add I ran a var_dump($_POST) right after my delete script to see what it was pulling as the value of POST and it came back with: Error.array(1) { ["Action"]=> string(6) "Delete" }
QuestionRe: How to Delete file when Selected from Dropdown List Pin
Richard MacCutchan10-Mar-15 22:08
mveRichard MacCutchan10-Mar-15 22:08 
AnswerRe: How to Delete file when Selected from Dropdown List Pin
Member 1150850510-Mar-15 22:11
Member 1150850510-Mar-15 22:11 
GeneralRe: How to Delete file when Selected from Dropdown List Pin
Richard MacCutchan10-Mar-15 23:10
mveRichard MacCutchan10-Mar-15 23:10 
QuestionDisplay results based on dropdown selected dropdown value Pin
samflex10-Mar-15 7:47
samflex10-Mar-15 7:47 
AnswerRe: Display results based on dropdown selected dropdown value Pin
tobisoft28-Apr-15 13:34
tobisoft28-Apr-15 13:34 
GeneralRe: Display results based on dropdown selected dropdown value Pin
nilprajapati8-Dec-15 22:13
nilprajapati8-Dec-15 22:13 
QuestionCan't get ubuntu boot to recognize USB drive! Pin
swampwiz22-Feb-15 7:46
swampwiz22-Feb-15 7:46 
QuestionHow Can I Detect Whether My Total Price Is Greater Than The Price I Inputted On Textbox Pin
Patrick sarmiento12-Feb-15 20:49
Patrick sarmiento12-Feb-15 20:49 
SuggestionRe: How Can I Detect Whether My Total Price Is Greater Than The Price I Inputted On Textbox Pin
Richard MacCutchan12-Feb-15 22:50
mveRichard MacCutchan12-Feb-15 22:50 
QuestionPass datepicker value to PHP & MySQL Pin
Jassim Rahma7-Feb-15 23:28
Jassim Rahma7-Feb-15 23:28 
AnswerRe: Pass datepicker value to PHP & MySQL Pin
Thomas Daniels8-Feb-15 2:59
mentorThomas Daniels8-Feb-15 2:59 
QuestionMake this Hashing in PHP Pin
Jassim Rahma28-Jan-15 21:05
Jassim Rahma28-Jan-15 21:05 
AnswerRe: Make this Hashing in PHP Pin
Richard MacCutchan28-Jan-15 21:24
mveRichard MacCutchan28-Jan-15 21:24 
Question$_COOKIE[session_name()] vs session_id() which one holds good? Pin
Jayapal Chandran28-Jan-15 10:11
Jayapal Chandran28-Jan-15 10:11 
QuestionApache2.sin do not peer *.pl domain Pin
pixcraft14-Jan-15 2:33
pixcraft14-Jan-15 2:33 
QuestionFlash drive on Linux Pin
ForNow13-Dec-14 14:28
ForNow13-Dec-14 14:28 
AnswerRe: Flash drive on Linux Pin
Michael Martin9-Jan-15 20:22
professionalMichael Martin9-Jan-15 20:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.