ayanex10 Posted December 14, 2006 Share Posted December 14, 2006 [color=red]====================================================<?php$req = 'numb=5UserEmail=ayanex675410@yahoo.com&Name=Ebun&Email=ebun@yahoo.com';$header = "POST /SendMessage.php HTTP/1.0\r\n";$header .= "Content-Type: application/x-www-form-urlencoded\r\n";$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";$fp = fsockopen ('www.xyz.com', 80);if (!$fp) {echo "error in connection"; die(); }fputs ($fp, $header . $req);$res = '';$headerdone = false;while (!feof($fp)) {$line = fgets ($fp, 1024);if (strcmp($line, "\r\n") == 0) {// read the header$headerdone = true;}else if ($headerdone){// header has been read. now read the contents$res .= $line;}}echo $res; die();?>====================================================[/color]The code above is to send an HTTP POST data to a file on my server. It works fine and very well but I just have a problem with fsockopen.I have a server that has many domain names registered under it. The above example works fine but if I change the host name to another domain on my server, it will always bounce back to the domain above (xyz.com).I discovered that all the domain names on my server resolve to only one IP address and this IP address in turn resolves to only one hostname (xyz.com).So what I need is a way to tell fsockopen to open exactly the domain name I specify as my host name and not the default domain name on my server. Remember I have many domain names on my server.Please is there a way to get around this. Please I need help as urgent as possibleMy head is craking over here. Quote Link to comment Share on other sites More sharing options...
btherl Posted December 14, 2006 Share Posted December 14, 2006 Try fsockopen('http://www.domain.com').The problem is most likely that the Host: header, which tells a webserver which site to server, is invalid. The server then falls back to serving the default site. If none of this works, try using the CURL functions.http://sg.php.net/manual/en/ref.curl.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.