5 posts
Posted 08 July 2012 - 09:54 PM
How do i make a website respond to a http.post sent by a program in computercraft?
I know that you use:
http.post("http://site.com", variables)
But how do i read these variables for example in an PHP file?
Thanks in advance! :)/>/>
88 posts
Location
Austria(German)
Posted 08 July 2012 - 09:57 PM
You should look more in an PHP-Forum than a lua-Forum!
Or is there any problems with http.post()?
5 posts
Posted 08 July 2012 - 10:01 PM
You should look more in an PHP-Forum than a lua-Forum!
Or is there any problems with http.post()?
No problems, i only want to know what
http.post("link","this") does and how i can read and respond to it from my site.
286 posts
Location
Bonn Germany
Posted 08 July 2012 - 10:14 PM
the php script can read out the post variables easily. Use the array $_POST
5 posts
Posted 08 July 2012 - 10:28 PM
the php script can read out the post variables easily. Use the array $_POST
Thanks i'll try that!
5 posts
Posted 09 July 2012 - 01:31 AM
the php script can read out the post variables easily. Use the array $_POST
Thanks i'll try that!
It works perfectly!
Only one more thing though, how do i respond with a code that has been generated for uploading the file?
i tried
return $key;
but that just responds with a blank value..
286 posts
Location
Bonn Germany
Posted 09 July 2012 - 10:06 AM
I guess that http.post returns that, what you would get when you view the source code of the website that get's generated when you visit the php-file with the same parameters (POST variables) via your webbrowser.
So your php code can return stuff using the function print("TEST") or the function echo("TEST") or simply echo "TEST"
Of course you can replace the "TEST" with your variables or concatenate them with others or a string ("TEST: "..$var)
Try getting a bit familiar with PHP if you want to use if-then-else constructions or for-/while-loops …