|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
POST with PHP.. help
<?
I have a script here, it posts data to a webserver (running ASP) The URL is (when reccived at the other server): www.webserver.se/mottag.asp?dest=$dest&text=$text&from=$from EXAKT like that, the vaules is not extracted from the variable.. I want the URL to be: www.webserver.se/mottag.asp?dest=JENNY&text=testar&from=070404040404 The values should be generated from a database.. please advice. function sendToHost($host,$method,$path,$data,$useragent=0) { // Supply a default method of GET if the one passed was empty if (empty($method)) $method = 'GET'; $method = strtoupper($method); $fp = fsockopen($host,80); if ($method == 'GET') $path .= '?' . $data; fputs($fp, "$method $path HTTP/1.1n"); fputs($fp, "Host: $hostn"); fputs($fp, "Content-type: application/x-www-form-urlencodedn"); fputs($fp, "Content-length: " . strlen($data) . "n"); if ($useragent) fputs($fp, "User-Agent: MSIEn"); fputs($fp, "Connection: closenn"); if ($method == 'POST') fputs($fp, $data); while (!feof($fp)) $buf .= fgets($fp,128); fclose($fp); return $buf; } $dest = "JENNY"; $text = "testar"; $from = "070404040404"; $string = ""; sendToHost('www.webserver.se','post','/mottag_sms.asp','dest=$dest&text=$text&from=$from'); ?> |
|
#2
|
|||
|
|||
|
RE: POST with PHP.. help
sendToHost('www.webserver.se','post','/mottag_sms.asp','dest=$dest&text=$text&from=$from');
Put those in double quotes rather than single quotes: sendToHost("www.webserver.se","post","/mottag_sms.asp","dest=$dest&text=$text&from=$from"); When you place things in single quotes, variable substitution does not happen. You need to use double quotes for what you want to do... |
|
#3
|
|||
|
|||
|
RE: POST with PHP.. help
Your script won't work if you tell it to use "GET", incidentally, since you're still passing in Content-Length.
Moreover, I wouldn't have the caller encode the data, I'd make $data be an array, of var => value, and then walk it, like this: |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > POST with PHP.. help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|