Hi,
(1) I have about 8-9 .php files which are far from complex. I first
used GET in all of them. Worked fine. Then I changed all method="get"
to method="post" and $_GET to $_POST with search-replace, thinking that
it should work, but, it seems the $_POST variables are not getting
populated. Then I tried a simple one-page script using post - works
fine. So what could be the problem? I am not using
import_request_variables() or any such advanced feature.
(2) How do you address the situation where you have several
simultaneous users of your web application and your script reads from
the same single file, and maybe writes to the same single file(keep
aside the case of poor design, I am talking of say a page hit counter,
or reading initial settings from the single file), will not several
copies of your code in memory reading the same file on disk cause
problems? is there some specific code for such a situation? I looked
for "threadsafe" and "multiple user" but could not get anything.
Any help is appreciated.
Joseph S. 6 1667
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Joseph S. napisa³(a): Hi, (1) I have about 8-9 .php files which are far from complex. I first used GET in all of them. Worked fine. Then I changed all method="get" to method="post" and $_GET to $_POST with search-replace, thinking that it should work, but, it seems the $_POST variables are not getting populated. Then I tried a simple one-page script using post - works fine. So what could be the problem? I am not using import_request_variables() or any such advanced feature.
Maybe you using something like:
echo "<a href=\"index?a=$a\">text</a>";
This is works only with $_GET.
Tom Wysocki
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDYTbOLaRVEfZTNaERAs59AJ9lWhreocKG3wTuUdqFIJ zObB0bFACcCu8D
IHtXYxGa5wywG5GH0aB2LV4=
=UOBG
-----END PGP SIGNATURE-----
Joseph S. wrote: Hi, (1) I have about 8-9 .php files which are far from complex. I first used GET in all of them. Worked fine. Then I changed all method="get" to method="post" and $_GET to $_POST with search-replace, thinking that it should work, but, it seems the $_POST variables are not getting populated. Then I tried a simple one-page script using post - works fine. So what could be the problem? I am not using import_request_variables() or any such advanced feature.
Do you submit the forms or do you build up a query portion of a URL? The
post method needs a <FORM> tag with form elements. It should be
submitted. With the get method, you can just call a URL with a query
portion.
(2) How do you address the situation where you have several simultaneous users of your web application and your script reads from the same single file, and maybe writes to the same single file(keep aside the case of poor design, I am talking of say a page hit counter, or reading initial settings from the single file), will not several copies of your code in memory reading the same file on disk cause problems? is there some specific code for such a situation? I looked for "threadsafe" and "multiple user" but could not get anything.
Any help is appreciated. Joseph S.
There are database servers that have addressed the locking and
multi-user problems for you and there are also free webcounters
available on the web. But if you want to do it with a file, you could
try to achieve a file lock. Depending on the OS, you could either
directly lock the file or work with a separate lockfile. Both have the
disadvantage that if anything goes wrong, the counter file remains
locked until you unlock it by hand.
An alternative approach is to run an external application (by using COM
on Windows, for example) that is the only process to touch the file.
Your PHP scripts can then call the external application for both reading
and writing.
Best regards
Joseph S. wrote: (1) I have about 8-9 .php files which are far from complex. I first used GET in all of them. Worked fine. Then I changed all method="get" to method="post" and $_GET to $_POST with search-replace, thinking that it should work, but, it seems the $_POST variables are not getting populated. Then I tried a simple one-page script using post - works fine. So what could be the problem?
Some typo somewhere... Say, you now have $POST or $_POTS instead of
$_POST...
(2) How do you address the situation where you have several simultaneous users of your web application and your script reads from the same single file, and maybe writes to the same single file
Reading from the same file on a modern operating system should
require no attention at all; it is handled on the OS level.
Writing... well, read up on flock() and see what the manual has
to say about OS-specific details... http://www.php.net/flock
I looked for "threadsafe" and "multiple user" but could not get anything.
Thread is a Windows-only concept. On Unix, there are no threads,
only full-blown processes, each with a distinct ID... This is
why file locking would work on Unix, but not on Windows...
Cheers,
NC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Joseph S. wrote: (2) How do you address the situation where you have several simultaneous users of your web application and your script reads from the same single file, and maybe writes to the same single file
Seems like the same old reader-writer concurrency problem. Use some method
to lock the files, in order to avoid multiple writes. See php.net/flock .
- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net
Los verdaderos programadores no trabajan de 9 a 6. Si puede verse alguno a
las 9, es porque ha estado toda la noche trabajando.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFDYTtP3jcQ2mg3Pc8RAjzpAKCIAnoVaMG/4ts3A20nacU4+Y9HzgCcCuM+
OkDdOCk0seC5EJ06bg1ioyI=
=tZN0
-----END PGP SIGNATURE-----
Hi,
It was not typos or urls with "name.php?q=whatever", it was the form
tag attribute enctype="text/plain" -
it was inserted by default in the form tag that is generated by
PHPEclipse
when you select the form option for post from the popup dropdown:
<form action="link" method="post" enctype="text/plain">
cursor
</form>
It does not work with POST but works with GET.
(which is why the fact that it is part of the default text for the form
post tag in PHPEclipse comes as a surprise - it does not work - I have
XAMPP installed Apache/2.0.54 PHP/5.0.4 )
What I found is that with post, the enctype attribute
must either be omitted completely:
<form action="myform.php" method="post">
</form>
or,
if specified, must be set to
enctype="application/x-www-form-urlencoded" or
enctype="mulitpart/form-data"
which work.
As for concurrent file access, as Dikkie pointed out,
it is better to use a database
and if only read is involved, the OS should takes care of it.
I read php.net/flock and it seems better to use a database, however
small.
Thanks all,
Regards,
Joseph. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: eScrewDotCom |
last post by:
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is very funny. eScrew...
|
by: eScrewDotCom |
last post by:
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is very funny. eScrew...
|
by: perseus |
last post by:
I think that everyone who told me that my question is irrelevant,
in particular Mr. David White,
is being absolutely ridiculous. Obviously, most of you up here
behave like the owners of the C++...
|
by: Matt |
last post by:
I wrote the tcp socket client-server program that the server will
echo the message received from the client.
In client program:
char sendBuf;
while(1)
{
cout << "Enter message:";...
|
by: eScrewDotCom |
last post by:
www.eScrew.com
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is...
| |
by: Suri |
last post by:
hi im trying to run this simple program. any help shall be appreciated
..pls see error message.
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double pic;
pic= 4.0 *...
|
by: eScrewDotCom |
last post by:
eScrew
Welcome to eScrew!
eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew
story if you promise eScrew to consider eScrew story as joke. eScrew
story is very funny. eScrew...
|
by: msxkim |
last post by:
My web app writes some binary data to a file at the client site via
Response.BinaryWrite. This action is accomplished
in response to a button click, with C# code behind as follows:
private void...
|
by: Markus Svilans |
last post by:
Hi,
I have a weird problem in a virtual method. The original method code
raises an access violation when it is run. The solution to the problem
is to declare a dummy integer inside the virtual...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |