Page 1 of 1

php call to separate server?

Posted: Sun Jan 18, 2009 11:40 pm
by cwls1184
Hi, I'm new here and I know how annoying newbies can be, so I apologize in advance but I really need to figure this out.

So I'm trying to write a program that someone can install on their server. When the program is run it will send a variable to a php file on my server. My file will process the data, and send basically just a true or a false back. All I need to know is how to send the variable to my file and the true or false back. :banghead: I'm sure you pros can answer this in like two seconds so I appreciate your help. :drunk: I'm also totally digging the icons here too.

Thanks

Re: php call to separate server?

Posted: Mon Jan 19, 2009 1:57 am
by requinix
I assume this "program" will be a PHP script?

Something as simple as this:

Code: Select all

if (file_get_contents("http://yoursite.com/path/to/script.php?variable=value") == "true") {
    // passes test
} else {
    // failed test
}
script.php uses $_GET["variable"] to decide what to do.

Code: Select all

<?php
 
header("Content-Type: text/plain"); // not necessary but I'd do it
 
// check if the data has not been sent
if (!isset($_GET["variable"])) { echo "false"; return; }
 
// do whatever you need to do
Now that I've answered, what do you need this for? Just curious.

Re: php call to separate server?

Posted: Thu Jan 22, 2009 10:26 pm
by cwls1184
tasairis,

Thanks I'll try it out. I finally got to the point where I can code that part of the program. 8)

As far as what I'm using it for. I have a membership area on my site, but I'm writing program for other people to put on their site and I want the program to be able to verify their membership info to post on their page. So it will basically ask if they've hit a certain level. My program will check my database and return either a true or false. So, I'm off hope your code works and thanks for the help.