Page 1 of 1

Set a variable to = a text input

Posted: Fri Oct 24, 2008 11:48 am
by odie2828
I have a text field named imagedel

i want

$myfile = 'imagedel'

Code: Select all

 
 <form name="form1" method="post" action="delete.php">
        <p>Delete Image?</p>
        <p> 
 
<input name="imagedel" type="text" value="<?php echo $pic; ?>" size="25" />
                </p>
        <p>
          <input type="submit" value="Delete" />
        </p>
    </form>
 

Code: Select all

 
 
 
<?php
$myfile = 'imagedel';
unlink($myfile);
?>
 
 
what is the proper coding for that?

Re: Set a variable to = a text input

Posted: Fri Oct 24, 2008 11:58 am
by odie2828
Or how can i have the unlink function use the file name that is in a text field to determine what file to delete?

Re: Set a variable to = a text input

Posted: Fri Oct 24, 2008 12:10 pm
by requinix

Re: Set a variable to = a text input

Posted: Fri Oct 24, 2008 12:31 pm
by oscardog

Code: Select all

 
$myfile = $_POST['imagedel'];
 

Re: Set a variable to = a text input

Posted: Fri Oct 24, 2008 12:32 pm
by onion2k
Do NOT just do something like unlink($_POST['myfile']); though. Validate it and make sure it's a file the user should be allowed to delete first.