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
276 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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 …

863 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

24 Experts available now in Live!

Get 1:1 Help Now