Jump to content

I'm Stumped Please help! (Interfacing with affiliate programs API)


Recommended Posts

This is a code to interface with an affiliate program's API it returns 2 responses..

 

If it is a successful join and the user name and email are valid it returns an

OK

then its supposed to redirect you to a page telling you to check your email

 

If the user name is taken it says

Handle 'lookimtrix123' is taken. Please enter another handle.

then its supposed to redirect you to a page telling you to try a different user name

 

I'm getting this error:

Parse error:  syntax error, unexpected '}' in /home/public_html/DaveSite/dave2/index.php on line 47

 

Also since the value's of the forms are variable's the form fields are empty and the form validation automatically puts the first error up above the form how do I fix that as well and I don't think I'm submitting the form correctly but I've tried everything looked thru almost 50 pages of help searched the forum, php.net, w3school etc.. I know the basic's of how coding works because I program in other languages and I have done small php stuff like geo locations, display ip etc but this one's stumped me please help  ??? BTW: attached is the pdf that the affiliate program gave me just shows the required variables.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
</head>
<?php
$ipi=($_SERVER['REMOTE_ADDR']);
$email=($_POST['email']);
$username=($_POST['username']);
//Is username longer then 3 characters?
if(strlen($username)<3)
   {
    echo 'Your username must be longer than 3 characters.<br />';
   }
//Is there a username?
else if(strlen($username)<1)
  {
    echo 'You must enter a username.<br />';
   }  
//Is the E-Mail Valid?
else if(!filter_var($email, FILTER_VALIDATE_EMAIL))
   {
    echo 'E-mail is not valid.<br />';
   }
//Everything looks valid now register!
function reg_horn() {
$s = fsockopen('hornymatches.com', 80);
fwrite($s, "POST /api_join_basic.php?f_email=$email&f_username=$username&campaign_id=20928&api_username=api88&api_password=password88 HTTP/1.1 Host: hornymatches.com Connection: close;  ");
while(!feof($s)) {
    $line = fgets($s);
      if(stripos($line, $username) !== false) {
                header("location:fail.php");
        }
        elseif(stripos($line, "OK") !== false) {
                header ("location:success.php");
        }
        
   else {
                header ("location:error.php");
        }
                break;
        }
     }
fclose($s);
}
?>
<input name="f_email" type="text" value="<?php echo $email ?>" maxlength="150" /><br />

<input name="f_username" type="text" value="<?php echo $username ?>" size="15" /><br />

<input name="Submit" type="submit" onmouseup="reg_horn()" />
</form>
<body>
</body>
</html>

 

[attachment deleted by admin]

The error message says all:

An unexpected } on line 47

 

With proper indention you could have seen the problem (see comment in the code):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
</head>
<?php
$ipi=($_SERVER['REMOTE_ADDR']);
$email=($_POST['email']);
$username=($_POST['username']);
//Is username longer then 3 characters?
if(strlen($username)<3)
   {
    echo 'Your username must be longer than 3 characters.<br />';
   }
//Is there a username?
else if(strlen($username)<1)
  {
    echo 'You must enter a username.<br />';
   }  
//Is the E-Mail Valid?
else if(!filter_var($email, FILTER_VALIDATE_EMAIL))
   {
    echo 'E-mail is not valid.<br />';
   }
//Everything looks valid now register!
function reg_horn() {
$s = fsockopen('hornymatches.com', 80);
fwrite($s, "POST /api_join_basic.php?f_email=$email&f_username=$username&campaign_id=20928&api_username=api88&api_password=password88 HTTP/1.1 Host: hornymatches.com Connection: close;  ");
while(!feof($s)) {
	$line = fgets($s);
	if(stripos($line, $username) !== false) {
		header("location:fail.php");
	} elseif(stripos($line, "OK") !== false) {
		header ("location:success.php");
	} else {
		header ("location:error.php");
	}
	break;
}
} // Where does this one belong to?
fclose($s);
}
?>
<input name="f_email" type="text" value="<?php echo $email ?>" maxlength="150" /><br />

<input name="f_username" type="text" value="<?php echo $username ?>" size="15" /><br />

<input name="Submit" type="submit" onmouseup="reg_horn()" />
</form>
<body>
</body>
</html>

Ok thanks that got rid of the error but the code still wont work.. I read over the stickys changed a few things around still does not work heres my updated code that DOES NOT work please help thanks!!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
<?php
function reg_horn() {
$s = fsockopen('hornymatches.com', 80);
fwrite($s, "POST /api_join_basic.php?f_email=$email&f_username=$username&campaign_id=20928&api_username=api88&api_password=password88 HTTP/1.1\nHost: hornymatches.com\nConnection: close;\n\n");
while(!feof($s)) {
    $line = fgets($s);
      if(stripos($line, $username) !== false) { //Did this because all im looking for is the usename that tells me its invalid
                header("location:fail.php");
        }
        elseif(stripos($line, "OK") !== false) {
                header ("location:success.php");
        }
        
   else {
                header ("location:error.php");
        }
                break;
        }
     
fclose($s);
}
?>
</head>
<input name="f_email" type="text" value="<?php echo $email ?>" maxlength="150" /><br />

<input name="f_username" type="text" value="<?php echo $username ?>" size="15" /><br />

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input name="Submit" type="submit" onclick="reg_horn()"/>
</form>
<?php
$ipi=($_SERVER['REMOTE_ADDR']);
$email=($_POST['email']);
$username=($_POST['username']);
//Is username longer then 3 characters?
if(strlen($username)<3)
   {
    echo 'Your username must be longer than 3 characters.<br />';
   }
//Is there a username?
else if(strlen($username)<1)
  {
    echo 'You must enter a username.<br />';
   }  
//Is the E-Mail Valid?
else if(!filter_var($email, FILTER_VALIDATE_EMAIL))
   {
echo 'E-mail is not valid.<br />';
   }
//Everything looks valid now register!
?>
<body>
</body>
</html>

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.