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
278 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 78
Image decoding from Camera 3 88
iframe detection of parent window scale 20 74
Difference between List and Array in Python 5 70
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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

803 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