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
272 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 142

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 142

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 142

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now