Forum Moderators: coopster

Message Too Old, No Replies

PHP snippet problem

         

tekomp

5:37 pm on Aug 16, 2005 (gmt 0)

10+ Year Member



Hi,

I have had a script written for membership management for a website, however, the programmer turned out to be less than competent and is no longer around. I'm not a programmer, but I'm still trying to debug as it sometimes works. This is the snippet I am having problems with:

global $account_no, $site_tag, $c_control_keyword;
$username = $_POST['username'];
$password = $_POST['password'];
$url = "http://example.com/selfservice1.2?".$account_no.":".$site_tag."&LOGIN_NAME=".$username."&PASS_WORD=".$password."";

ob_start();
$response = join("", file($url));
ob_end_flush();

$nnpos = strpos($response, "\n\n");
$creation_result_string = strip_tags(substr($response, $nnpos + 1));

if (strpos($creation_result_string, "cancel membership")!== false && strpos($creation_result_string, "No") === false)
{

include("offer.html");
} else {
include("error.html");
}
} else {
echo "Access Denied";
}

-----
This code is checking to see that the username and password exists by querying the URL, and *I think* it's doing so by checking the source code of the page it posts to and is searching for the "cancel membership" string. Is that correct? Is there a better way to parse the result page for this string?

The problem that I am having is that sometimes error.html is returned, even though the member does exist and I can verify by going to the /selfservice1.2 URL manually and I can see that the page does indeed contain the string "cancel membership".

Hopefully I provided enough info. Thanks for your help.

coopster

10:01 pm on Aug 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




and is searching for the "cancel membership" string. Is that correct?[

Somewhat. There are two conditions there. In plain language, it says something like this ...

If I do not find the phrase "cancel membership" 
AND
If I do not find the word "No" (after the first position)
THEN
include the offer.html page
OTHERWISE for all other conditions
include the error.html page

tekomp

4:10 am on Aug 17, 2005 (gmt 0)

10+ Year Member



That helped. I think I got it working right now. Thanks!