Jump to content

fsockopen() only opens one out of all the domains on my server. Need Urgent Help


ayanex10

Recommended Posts

[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 possible

My head is craking over here.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.