Solved

How can I send a variable from a text field in an html doc to a php page?

Posted on 2006-11-01
6
279 Views
Last Modified: 2010-04-16
Ultimately I need to send a variable which is really a web address to a php page after a button is clicked on the html page.

The two issues I currently have are:

I'm not entirely sure how to build the html page that will send a variable that the php page would recognize.  I successfully built an upload page with no problem, but this delete page, which you type in the web address that has permissions to delete a certain file seems totally unrelated.  

html page so far for deleting interface:

<FORM ACTION="deleteTest.php" NAME="application">
application date: <INPUT TYPE=TEXT NAME="deletedFile" SIZE=10>
<P>
<BUTTON TYPE=RESET><FONT COLOR=RED>Reset Form</FONT></BUTTON>
<BUTTON TYPE=SUBMIT><STRONG>Send address to delete</STRONG></BUTTON>
</FORM>

I was guessing that the name of the variable could go under "deletedFile" but I know this is probably totally wrong.

deleteTest.php I know would probably be extremely simple:

<?php
$myFile = 'deletedFile';
unlink($myFile);
?>

Again, 'deletedFile' would be the variable of the web address that the user types in.

Thanks.
0
Comment
Question by:bostoncybertech
  • 3
  • 3
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 17853053
listening &<FORM ACTION="deleteTest.php" NAME="application" METHOD="POST" >
application date: <INPUT TYPE=TEXT NAME="deletedFile" SIZE=10>
<P>
<BUTTON TYPE=RESET><FONT COLOR=RED>Reset Form</FONT></BUTTON>
<BUTTON TYPE=SUBMIT><STRONG>Send address to delete</STRONG></BUTTON>
<INPUT TYPE="HIDDEN" NAME="FILE_TO_DELETE" VALUE="the_file_path"></INPUT>
</FORM>


and in your deleteText.php you can get the hidden input variable:

<?php
$myFile = $_POST["FILE_TO_DELETE"];
unlink($myFile);
?>
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17853056
ps: you should post this kind of questions rather in the web development topic area...
0
 

Author Comment

by:bostoncybertech
ID: 17853212
For some reason I get this:

Warning: unlink(the_file_path): No such file or directory in /home/homes/bostoncybertech/http.www.bostoncybertech.com/test/deleteTest.php on line 3
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17853234
i am sorry... I didn't see you had already a input button for the file to delete (sig)

<FORM ACTION="deleteTest.php" NAME="application" METHOD="POST" >
application date: <INPUT TYPE=TEXT NAME="deletedFile" SIZE=10>
<P>
<BUTTON TYPE=RESET><FONT COLOR=RED>Reset Form</FONT></BUTTON>
<BUTTON TYPE=SUBMIT><STRONG>Send address to delete</STRONG></BUTTON>
</FORM>


and in your deleteText.php you can get the input variable:

<?php
$myFile = $_POST["deletedFile"];
unlink($myFile);
?>

note that the FORM got the METHOD="POST" attribute which is important... just in case you had not seen that.
0
 

Author Comment

by:bostoncybertech
ID: 17853349
Thanks for your help.  I still get the same error:
Warning: unlink(http://www.bostoncybertech.com/test/uploads/Winter.jpg): No such file or directory in /home/homes/bostoncybertech/http.www.bostoncybertech.com/test/deleteTest.php on line 3

All I want this to do is delete a file specified by a web address that has the appropriate permissions to delete.
0
 

Author Comment

by:bostoncybertech
ID: 17853945
I understand the issue I have now.  Delete can not look at a web address. I have to put the delete html and php files in the directory of the files and type an address as simple as a file name, and not a full path and it works.  Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question