Loading...
Logo
Processing Forum

PHP POST/GET

in General Discussion  •  Other  •  10 months ago  

Hello, how can I send data to the server using POST method?
Can you write a piece of code?(Processing)

Thank you very much.
File.PHP
Copy code
  1. <?php
  2. $data=(int)$_POST["message"]; // get the message from the phone
  3. if($data==1)
  4. {
  5. .....
  6. .........
  7. }
  8. ?>
If it were not possible with the POST method as I do with the GET method?

Replies(4)

Re: PHP POST/GET

10 months ago
GET method is simple: use loadString() with the parameters in the URL.
POST is a bit more complex. You have an example at http://wiki.processing.org/w/Saving_files_to_a_web-server which was the base for my http://processing.org/discourse/yabb2/YaBB.pl?num=1212658813/15#15 code, which in turn was used to do the PostToWeb library.

Re: PHP POST/GET

10 months ago
Thanks for the quick response
Can you give an example of how to use  loadStrings?
I only found this on the internet 
Copy code
  1. String [] response = loadStrings("http://www.yourwebsite.com/sketch/log.php?a=5&b=7");      
If you do me a working example you do me a big favor ^ - ^


Re: PHP POST/GET

10 months ago
Well, you gave yourself a working example... It is as simple as that.

Re: PHP POST/GET

10 months ago
Thank you so much, I put the code below, maybe it can be helpful.

Processing code
Copy code
  1. String [] response = loadStrings("http://WebSiteName/Test/welcome.php?fname=xsanciopanzax&age=18");
  2. println(response);

PHP FILE
welcome.php

Copy code
  1. Welcome <?php echo $_GET["fname"]; ?>.<br>
  2. You are <?php echo $_GET["age"]; ?> years old!

Result:(Console of Processing )

Copy code
  1. [0] "Welcome xsanciopanzax.<br>"
  2. [1] "You are 18 years old!"