Set a variable to = a text input

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
odie2828
Forum Commoner
Posts: 39
Joined: Tue Aug 05, 2008 4:40 pm

Set a variable to = a text input

Post 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?
odie2828
Forum Commoner
Posts: 39
Joined: Tue Aug 05, 2008 4:40 pm

Re: Set a variable to = a text input

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Set a variable to = a text input

Post by requinix »

oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Set a variable to = a text input

Post by oscardog »

Code: Select all

 
$myfile = $_POST['imagedel'];
 
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Set a variable to = a text input

Post 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.
Post Reply