Code: Select all
URL url;
URLConnection con;
OutputStream oStream;
String parametersAsString;
byte[] parameterAsBytes;
String aLine; // only if reading response
parametersAsString = "msg=hello&to=world";
parameterAsBytes = parametersAsString.getBytes();
// send parameters to server
url = this.getCodeBase();
url = new URL(url + "index.php3");
con = url.openConnection();
con.setDoOutput(true);
// setDoInput(true); // only if reading response
con.setDoInput(false);
con.setRequestProperty("Content=length", String.valueOf(parameterAsBytes.length));
oStream = con.getOutputStream();
oStream.write(parameterAsBytes);
oStream.flush();
oStream.close();Code: Select all
<?php
$str = "post?... ";
if ($_POST) {
$str .= print_r($_POST);
} else {
$str .= "apparently not";
}
echo file_put_contents("savings.txt", str);
?>Tom