You are here: Re: connect to same page $_POST in <a> tag « PHP SQL « IT news, forums, messages
Re: connect to same page $_POST in <a> tag

Posted by JDS on 10/10/05 19:07

On Mon, 10 Oct 2005 11:28:37 -0400, Doug wrote:

> The existing web page https://st23.startlogic.com/~libertys/download.php has
> downloads at the bottom of the page. When a user clicks on a link the
> browser goes into the download mode and the user downloads the file. What I
> am trying to do is run a MySQL query in PHP (same page because there is a
> header call for the form data) to store the version string ("cbverxxx.exe")
> and present date of download. The way the code exists to do this (download
> the file) is as shown in my last post noted above.
>
> On a Windows directory reference 'Download Files', spaces are allowed and it
> has worked so far in all of the Windows code I have written.

I see. I'll answer the "spaces in filenames" part first.

Spaces are allowd in Windows file and directory names, yes. In fact, they
are allowed in Linux, Mac, and other OS file and directory names.

They are NOT, however, allowed in URLs (even though browsers are flexible
enough to compensate). A space in a URL should be encoded as "%20".
There are a number of reasons why you should follow this suggestion, but
that is an aside...

Now, back to point in hand. To have the string of PHP code "get" the
value of the $_GET variables when the link is clicked, the link has to
point to the PHP page, like so (assuming the page is called "booger.html"):

<a href="booger.html?ver=1.23">Download Version 1.23 of This File</a>

Then the PHP can use the SQL statement to track the version chosen. But
what about the download? Well, you will have to point the script to the
download file at that point by one of three ways:

* Use a redirect header to redirect to the proper download file
* Read the file into a variable, send the proper MIME headers, and then
output the binary contents of the file.
* Some other way I haven't thought of. There is *always* another way to
do something.

The first one is easiest, but offers the least control and security
options. The second way is more flexible and potentially secure, but
harder to implement.

See:
http://us2.php.net/header
http://us2.php.net/manual/en/function.file-get-contents.php
http://us2.php.net/manual/en/function.fopen.php
etc...

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация