Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 375 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

604 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