Jump to content

hana2410

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hana2410's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you Crayon Violent for letting me know that unlink only deletes the file out of the directory but not the database as well as showing me how to update my database to display a Null value. After some more testing, I've realised that the reason why my images are not being deleted from the directory is that the "remove_pic" and $accountid variables are not being passed onto the script which is above the form. The form action is $editFormAction. When I take away the isset function I get index and variable undefined messages. Does anyone know I can pass the values of the variables in the form to the script? Your help is appreciated.
  2. Hi, I have created a form where people can update their information with the option of deleting their picture using a checkbox. If a person wishes to to delete their picture, all they need to the do is click on the checkbox and their picture will be removed when the form is updated. My problem is that I can not get my script to unlink and delete the image location from my database. The update script for the other form fields works fine. I'm not sure what I am doing wrong as I do not receive any error messages. Here's my unlink code: [code]$editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) {   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if (isset($editFormAction)) {     if ((isset($_POST['remove_pic'])) && ($_POST['remove_pic'] == "cbox")) {     mysql_select_db($database_conn, $conn) or die(mysql_error());     $id = (isset($_POST['id'])) or die(mysql_error());     $sql = "Select file from table Where id = '" .$id. "' " or die(mysql_error());     $result2 = mysql_query($sql, $conn) or die(mysql_error());     $ddata2 = mysql_fetch_assoc($result2) or die(mysql_error());     $name = $ddata2['file'] or die(mysql_error());         if (is_file($name)) {             unlink($name) or die(mysql_error());         }     } }[/code] Here's my form code: [code]<?php if ($row_info['file']!= "") { echo '<tr><td nowrap div align="right" class="style6">Current Picture</td> <td><img src="' .$row_info['file']. '"></td> </tr><tr><td nowrap div align="right" class="style6">Delete Current Picture?</td><td><input type="checkbox" name="remove_pic" value="cbox"></td><td class="style14">(To delete your picture, tick the checkbox) </td></tr>'; } else { echo ""; } ?>[/code] I also have a hidden field in my form that has the account id in it. I appreciate any help in helping me to get my script to work. Thanks in advance
×
×
  • 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.