MrC88 Posted May 12, 2009 Share Posted May 12, 2009 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] Quote Link to comment https://forums.phpfreaks.com/topic/157777-im-stumped-please-help-interfacing-with-affiliate-programs-api/ Share on other sites More sharing options...
Philip Posted May 12, 2009 Share Posted May 12, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/157777-im-stumped-please-help-interfacing-with-affiliate-programs-api/#findComment-832190 Share on other sites More sharing options...
MrC88 Posted May 12, 2009 Author Share Posted May 12, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/157777-im-stumped-please-help-interfacing-with-affiliate-programs-api/#findComment-832212 Share on other sites More sharing options...
MrC88 Posted May 13, 2009 Author Share Posted May 13, 2009 ??? ??? Any support?? this is a roadblock in my project I'm kind of at a stand still till I get this figured out and I need to move forward asap. Thanx in advance Quote Link to comment https://forums.phpfreaks.com/topic/157777-im-stumped-please-help-interfacing-with-affiliate-programs-api/#findComment-833021 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.