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
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
<!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('mysite.com', 80);
fwrite($s, "POST /api_join_basic.php?f_email=$email&f_username=$username&campaign_id=20928&api_username=api88&api_password=password HTTP/1.1\nHost: mysite.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>