SA-MP Forums Archive
HTTP_POST. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: HTTP_POST. (/showthread.php?tid=183919)



HTTP_POST. - Luk_Ass - 17.10.2010

If I write more lines with HTTP_POST lines in file are absolutley random.

pawn Код:
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=1. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=2. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=3. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=4. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=5. line", "", "");

dest.txt
Код:
5.
2.
3.
4.
1.
...then
Код:
1.
3.
5.
2.
4.
Every time another sequence.


test.php
Код:
<?php
if (isset($_GET["filename"]) && isset($_GET["input"]))
{
    $readfile = fopen("files/".$_GET["filename"], "a");
    chmod("files/".$_GET["filename"], 0777);
    fwrite($readfile, $_GET["input"]."\r\n");
    fclose($readfile);
}
?>



Re: HTTP_POST. - Slice - 17.10.2010

You're sending the HTTP requests at the exact same time, there is no way of deciding which will reach the server first.


Re: HTTP_POST. - i514x - 17.10.2010

and why are you using HTTP_POST if you're not sending any post variables?


Re: HTTP_POST. - Luk_Ass - 17.10.2010

Pawn script is sequential. So first is send 1. line, then 2., 3., 4., 5., ...
But you're right. All 5 lines are sent only in 1-3ms.

I tryed to open:
Код:
myweb.cz/test.php?filename=dest.txt&input=1. line
myweb.cz/test.php?filename=dest.txt&input=2. line
myweb.cz/test.php?filename=dest.txt&input=3. line
myweb.cz/test.php?filename=dest.txt&input=4. line
myweb.cz/test.php?filename=dest.txt&input=5. line
myweb.cz/test.php?filename=dest.txt&input=6. line
myweb.cz/test.php?filename=dest.txt&input=7. line
myweb.cz/test.php?filename=dest.txt&input=8. line
myweb.cz/test.php?filename=dest.txt&input=9. line
myweb.cz/test.php?filename=dest.txt&input=10. line
myweb.cz/test.php?filename=dest.txt&input=11. line
myweb.cz/test.php?filename=dest.txt&input=12. line
myweb.cz/test.php?filename=dest.txt&input=13. line
myweb.cz/test.php?filename=dest.txt&input=14. line
myweb.cz/test.php?filename=dest.txt&input=15. line
myweb.cz/test.php?filename=dest.txt&input=16. line
myweb.cz/test.php?filename=dest.txt&input=17. line
myweb.cz/test.php?filename=dest.txt&input=18. line
myweb.cz/test.php?filename=dest.txt&input=19. line
myweb.cz/test.php?filename=dest.txt&input=20. line
At the same time in mozilla.

1st result:
Код:
2. line
1. line
4. line
3. line
5. line
6. line
7. line
8. line
9. line
10. line
11. line
12. line
13. line
14. line
15. line
16. line
17. line
18. line
19. line
20. line
Second result:
Код:
1. line
2. line
3. line
4. line
6. line
5. line
7. line
8. line
10. line
11. line
12. line
9. line
13. line
14. line
15. line
16. line
17. line
18. line
19. line
20. line
So it isn't a SA:MP bug. I have to make small intervals between sending.


EDIT:
Quote:
Originally Posted by i514x_
Посмотреть сообщение
and why are you using HTTP_POST if you're not sending any post variables?
test.php?filename=var1&input=var2


Re: HTTP_POST. - i514x - 17.10.2010

you're sending variables via GET to PHP not via POST
so you should change HTTP_POST to HTTP_GET

//edit: if you want it via POST do it like that:

pawn Код:
HTTP(playerid, HTTP_POST, "myweb.cz/test.php", "filename=dest.txt&input=1. line", "");



Re: HTTP_POST. - Luk_Ass - 17.10.2010

I am not sure but I think HTTP(playerid, HTTP_POST, "myweb.cz/test.php", "filename=dest.txt&input=1. line", ""); and HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=1. line", "", ""); is the same.
However my method works.


Re: HTTP_POST. - Slice - 17.10.2010

No, when you put contents in the query string (protocol://address.domain/path?query string#hash, you only need to do a GET request. POST requests should only be used when you send stuff in the data parameter for HTTP (you access those in PHP with $_POST[ .. ]).