"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< if($associate2tennisplayer) $debug .= "associate2tennisplayer=true
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< if($emailpasswordfilled) $debug .= "emailpasswordfilled=true
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< // create a2tp link only on register page and store user data if($p=="register"){ // logged in and is associate if($loggedinassociate){ $debug .= "loggedinassociate gives script to a2tp if zip is right
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $q = mysql_query("SELECT * FROM userdetails WHERE uid='".$_SESSION['uid']."'",$con); $r = mysql_fetch_array($q); // stored userdetails $DBfname = $r['fname']; $DBlname = $r['lname']; $DBaddress = $r['address']; $DBstate = $r['state']; $DBdob3 = $r['dob']; $DBemail = $r['email']; $DBphone1 = $r['phone1']; $DBphone2 = $r['phone2']; $DBphonenotes = $r['phonenotes']; $DBzip = $r['zip']; $DBusedrebatecode = $r['rebatecode']; // to later check that you dont join, opt out, and re-join w new rebatecode $DBa2tprbts = $r['a2tprcts']; // ts activated if rebatecode is new and stays until confirmed transfer to tennisplayer $a2tp_link = "Your zip code $DBzip does not belong to any TennisLadder, so you can't upgrade your account. If you think we should add it to a TennisLadder please email us though the contact form on the bottom of the page."; // option 2 // CHECK ZIP CODE AGAINST LADDERS $q = mysql_query("SELECT * FROM iptoziptolid WHERE ZIPCODE='".$DBzip."' AND LADDERID>0 LIMIT 1",$con); if(mysql_num_rows($q)==1){ $r = mysql_fetch_array($q); $DBlid = $r["LADDERID"]; $q = mysql_query("SELECT * FROM ladderdata WHERE lid='".$DBlid."'",$con); if(mysql_num_rows($q)==1){ $r = mysql_fetch_array($q); $DBladdername = $r["laddername"]; $noneblock1 = ($associate2tennisplayer) ? "none" : "block"; // default block $noneblock2 = ($associate2tennisplayer) ? "block" : "none"; // default none // swich on/off a2tp/tp $a2tp_link = " Your zip code $DBzip belongs to the ".$DBladdername." TennisLadder.
Click here to upgrade your Associate account to a TennisLadder membership!
You changed the join form to allow you to upgrade from Associate to TennisPlayer.
Click here to swich back.
"; } } } // not logged in or logged in as tennisplayer else $a2tp_link = "Associates can upgrade to TennisPlayer membership here after logging in."; } if($emailpasswordfilled OR $associate2tennisplayer){ $debug .= "emailpasswordfilled OR associate2tennisplayer
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< if($emailpasswordfilled){ $debug .= "emailpasswordfilled = check that data
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< // EMAIL $email = strtolower(check_input($_POST['email'])); if(empty($email)) $errors["email"] = "You left the email field blank."; else{ require_once 'is_email-3.01.php'; // is user a valid email? if (is_email($email)) { $q = mysql_query("SELECT * FROM users WHERE email='$email'",$con); if(mysql_num_rows($q)) { // email exist in database, check if its activated $r = mysql_fetch_array($q); $uid = $r['uid']; $active = $r['active']; if($active==1) { $q = mysql_query("SELECT * FROM userdetails WHERE uid='$uid'",$con); $r = mysql_fetch_array($q); $DBisplayer = $r['isplayer']; $isplayer = check_input($_POST['isplayer']); if($DBisplayer=='N' AND $isplayer=='Y') $errors["email"] = "$email is already registered as Associate. But you can upgrade to a TennisLadder membership if your zip code belongs to a ladder."; else $errors["email"] = "$email is already registered."; } else $_SESSION['joined'] = $email; } } else { $errors["email"] = "$email is not a valid email address"; } } // PASSWORD $pass1 = check_input($_POST['pass1']); $pass2 = check_input($_POST['pass2']); if(empty($pass1) OR empty($pass2)) $errors["pass"] = "Please write your chosen password in both fields."; else { if($pass1!==$pass2) $errors["pass"] = "Password verification failed."; elseif(strlen($pass1)<8) $errors["pass"] = "Please choose a password between 8 and 30 characters"; } // FIRST NAME $fname = check_input($_POST['fname']); if(empty($fname)) $errors["fname"] = "Empty First Name field"; elseif(strlen($fname)<2) $errors["fname"] = "Incorrect First Name"; // LAST NAME $lname = check_input($_POST['lname']); if(empty($lname)) $errors["lname"] = "Empty Last Name field"; elseif(strlen($lname)<2) $errors["lname"] = "Incorrect Last Name"; // ADDRESS $address = check_input($_POST['address']); if(empty($address)) $errors["address"] = "Empty Address field"; elseif(strlen($address)<2) $errors["address"] = "Incorrect Address field"; // CITY $city = check_input($_POST['city']); if(empty($city)) $errors["city"] = "Empty City field"; elseif(strlen($city)<2) $errors["city"] = "Incorrect City field"; // STATE $state = check_input($_POST['state']); if(state=="") $errors["state"] = "Choose State"; // ZIP $zip = ereg_replace("[^0-9]", "", $_POST['zip']); if(strlen($zip)==0) $errors["zip"]="No Zip Code."; elseif(strlen($zip)!=5) $errors["zip"]="Wrong Zip Code."; // DATE OF BIRTH $birthmonth = $_POST['birthmonth']; $birthday = $_POST['birthday']; $birthyear = $_POST['birthyear']; if($birthmonth=="" OR $birthday=="" OR $birthyear=="") $errors["birthdate"]="Select your birthdate."; // if todays date is less than 16th birthday = client under 16 years old elseif(date("Ymd") < date("Ymd", mktime(0,0,0,$birthmonth,$birthday,$birthyear+16))) $errors["birthdate"]="You have to be min. 16 years to join."; else { $dob = date("mdy", mktime(0,0,0,$birthmonth,$birthday,$birthyear)); $dob2 = date("Ymd", mktime(0,0,0,$birthmonth,$birthday,$birthyear)); $dob3 = date("m/d/Y", mktime(0,0,0,$birthmonth,$birthday,$birthyear)); } // PHONE 1 $phone1 = ereg_replace("[^0-9]", "", $_POST['phone1']); if(strlen($phone1)!=10) $errors["phone1"]="Wrong phone number."; // PHONE 2 $phone2 = ereg_replace("[^0-9]", "", $_POST['phone2']); if(strlen($phone2)!=0 AND strlen($phone2)!=10) $errors["phone2"]="Wrong phone number."; // NOTES $phonenotes = check_input($_POST['phonenotes']); } // ACCOUNT TYPE - depending on if $p = "register" or "associate" $isplayer = check_input($_POST['isplayer']); // Y=Yes, N=No, (W=Was) $rebatesum=0; // default if($isplayer=="Y"){ // in other words - if the tennisplayer page was loaded - so it could be if($p=="register") $debug .= "_POST['isplayer']='Y'
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< // GENDER $gender = check_input($_POST['gender']); if($gender=="") $errors["gender"] = "Select your Gender."; // NTRP $ntrp = check_input($_POST['ntrp']); if($ntrp=="") $errors["ntrp"] = "Select your NTRP Rating."; // PLAY SOCIALLY $playsocially = check_input($_POST['playsocially']); if($playsocially=="") $errors["playsocially"] = "Choose Yes or No."; // AGREEMENT $agree = check_input($_POST['agree']); if($agree!="on") $errors["agree"] = "Please check the box."; // NOTES $homecourt = check_input($_POST['homecourt']); $playtimes = check_input($_POST['playtimes']); // ($rank is decided after final activation) if($associate2tennisplayer) $a2tprcts = 1; // DEFAULT, picked up in inc_activate.php $debug .= "associate2tennisplayer
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< // CHECK REBATECODE $used_rebatecode = strtolower(check_input($_POST['rebatecode'])); if(!empty($used_rebatecode)){ $debug .= "used_rebatecode
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $rres = mysql_query("SELECT * FROM rebatecodes WHERE rebatecode='$used_rebatecode'",$con); // REBATECODE EXIST? if(mysql_num_rows($rres) == 1){ $debug .= "rebatecode $used_rebatecode exist
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $row = mysql_fetch_array($rres); $uid_rebategiver = $row['payto_uid']; $debug .= "uid_rebategiver=$uid_rebategiver
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< // if a2tp transform is finished then a2tprbts ts is reset to 0. // as long as a2tprbts has ts the rank and the isplayer has not changed $debug .= "check if($DBusedrebatecode!='' AND $DBa2tprbts==0) =prev used rc
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $debug .= "check if(associate2tennisplayer==true AND uid_rebategiver $uid_rebategiver == ".$_SESSION['uid']." _SESSION['uid']) =no use own rc
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< if($DBusedrebatecode!="" AND $DBa2tprbts==0) $errors["rebatecode"] = "You have previously used a rebate code so you can't use one again."; //elseif($associate2tennisplayer==true AND $uid_rebategiver==$_SESSION['uid']) $errors["rebatecode"] = "Nice try, but you can't use your own rebate code."; else{ $debug .= "seems rc is first time use + not my own
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $a2tprcts = $utc_ts; // TIMESTAMP, associate to tennisplayer rebatecode timestamp IF REBATECODE used for very first time $codetype = $row["codetype"]; // refdate|refrand|email|promo $rebatesum = $row["rebatesum"]; if($codetype=="promo"){ $debug .= "get promo rc details
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< if(date("Ymd")<$row["datestart"]) $errors["rebatecode"] = "Rebate code is not activated yet."; // << adjust date later to local date $dateend = $row["dateend"]; if($dateend!=0 AND date("Ymd")>$dateend) $errors["rebatecode"] = "Rebate code has expired."; $promoname = $row["promoname"]; $promo_uid = $row["payto_uid"]; $q = mysql_query("SELECT * FROM promos WHERE uid='$promo_uid'",$con); $r = mysql_fetch_array($q); $promobusinessname = $r['bname']; } } } else $errors["rebatecode"] = "Invalid rebate code."; } if($emailpasswordfilled){ // CHECK ZIP CODE AGAINST LADDERS $debug .= "SELECT * FROM iptoziptolid WHERE ZIPCODE='$zip' AND LADDERID>0 LIMIT 1
"; // ************ $q = mysql_query("SELECT * FROM iptoziptolid WHERE ZIPCODE='$zip' AND LADDERID>0 LIMIT 1",$con); if(mysql_num_rows($q)==1){ $r = mysql_fetch_array($q); $lid = $r["LADDERID"]; $debug .= "LADDERID lid found $lid
"; // ************ $debug .= "SELECT * FROM ladderdata WHERE lid='$lid'
"; // ************ $q = mysql_query("SELECT * FROM ladderdata WHERE lid='$lid'",$con); if(mysql_num_rows($q)==1){ $r = mysql_fetch_array($q); $laddername = $r["laddername"]; $debug .= "laddername found $laddername
"; // ************ } } // MAIL US IF ZIP CODE MISSING if(empty($errors) AND empty($laddername)) { $errors["zip"] = "No ladder YET with this zip code. We have been alerted and we will check if the zip can be added to a ladder. We might contact you about it."; $mailaboutmissingzip = true; } } } // CREATE MAIL MESS $assplay = ($isplayer=="N") ? "associate" : "tennisladder"; if($associate2tennisplayer) { $assplay = "a2tp"; $address = $DBaddress; $state = $DBstate; $zip = $DBzip; $dob3 = $DBdob3; $email = $DBemail; $phone1 = $DBphone1; $phone2 = $DBphone2; $phonenotes = $DBphonenotes; $laddername = $DBladdername; $lid = $DBlid; } $premembermessage = "$assplay PRE MEMBER: Name: $fname $lname Address: $address State, Zip: $state $zip Born: $dob3 Email: $email Phone1: $phone1 Phone2: $phone2 Phonenotes: $phonenotes Gender: $gender NTRP: $ntrp Ladder: $laddername Playsocially: $playsocially (1=yes, 0=no) Homecourt: $homecourt Playtimes: $playtimes Used Rebatecode: $used_rebatecode Codetype: $codetype RebateSum: $rebatesum "; // NO ERRORS = CREATE USER if(empty($errors)){ $md5email = md5("z".$email.time()); $codetype2 = ($codetype=='') ? 'no rebate' : $codetype; if($associate2tennisplayer){ $debug .= "if associate2tennisplayer update userdetails
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< mysql_query("UPDATE userdetails SET gender='$gender', ntrp='$ntrp', lid='$lid', playsocially='$playsocially', homecourt='$homecourt', playtimes='$playtimes', rebatecode='$used_rebatecode', a2tprcts='$a2tprcts' WHERE email='$email'",$con); // isplayer='$isplayer' $uid = $_SESSION['uid']; mail($chris, "#$uid $fname $lname [$assplay re-register initial $codetype2]", $premembermessage, $headers); mail($paul, "#$uid $fname $lname [$assplay re-register initial $codetype2]", $premembermessage, $headers); $_SESSION['a2tp']='updated'; // for inc_registrationcomplete.php if($rebatesum>0 AND $codetype=="promo"){ $activate=true; include("inc_activate.php"); // FINISH UP BY SHOWING CONFIRMED PAGE $_SESSION = array(); // destroy all of the session variables = LOGOUT anyone else $_SESSION['uid'] = $uid; $_SESSION['email'] = $email; //$_SESSION['my_rebatecode'] = $my_rebatecode; // no new creation of rebatecode $_SESSION['confirmedaccount'] = $message; // for inc_confirmedaccount.php to pick up $_SESSION['activate'] = "success"; // gives $confirmedaccount=true; in loginout.php // used for index.php > [loginout.php] > register.php > inc_confirmedaccount.php //$_SESSION['debug'] = "activatingnewmember: confirmedaccount message, activate success
"; //$p = "register"; // $p = ($associate) ? "associate" : "register"; } else { //$_SESSION['joined']=$email; $rc = array($uid,$email,$isplayer,$rebatesum,$codetype,$promoname,$promobusinessname,$md5email); $_SESSION['registrationcomplete'] = $rc; } } elseif($emailpasswordfilled){ $debug .= "if emailpasswordfilled update users, userdetails, userstemp
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $salt = generate_salt(5); $pass = hash('sha256', $salt . hash('sha512', $pass1)); $timeonedayfromnow = $utc_ts + (24*60*60); // UTC TIME!!!!!!! // re-registered if($_SESSION['joined']==$email){ mysql_query("UPDATE users SET password='$pass', salt='$salt' WHERE email='$email'",$con) OR die("Error: ".mysql_error()); mysql_query("UPDATE userdetails SET rebatecode='$used_rebatecode', fname='$fname', lname='$lname', address='$address', state='$state', dob='$dob', dob2='$dob2', phone1='$phone1', phone2='$phone2', gender='$gender', ntrp='$ntrp', zip='$zip', lid='$lid', playsocially='$playsocially', phonenotes='$phonenotes', homecourt='$homecourt', playtimes='$playtimes', isplayer='$isplayer' WHERE email='$email'",$con); $q = mysql_query("SELECT * FROM users WHERE email='$email'",$con); $r = mysql_fetch_array($q); $uid = $r['uid']; // leave userstemp time mysql_query("UPDATE userstemp SET md5email='$md5email' WHERE uid='$uid'"); // OUR RECORDS mail($chris, "#$uid $fname $lname [$assplay re-pre-register initial $codetype2]", $premembermessage, $headers); mail($paul, "#$uid $fname $lname [$assplay re-pre-register initial $codetype2]", $premembermessage, $headers); $reregister = "

You registered your email AGAIN which is possible since you have not yet ACTIVATED your account.

"; } else { // DB users $query = mysql_query("INSERT INTO users (email, password, salt) VALUES ('$email','$pass','$salt')",$con) OR die("An error occurred (1). Please try again or contact us. ".mysql_error()); $uid = mysql_insert_id(); // DB tempuser mysql_query("INSERT INTO userstemp SET uid='$uid', md5email='$md5email', onedayfromnow='$timeonedayfromnow'",$con) OR die("An error occurred (2). Please try again or contact us. ".mysql_error()); // DB userdetails mysql_query("INSERT INTO userdetails (uid, joined, rebatecode, fname, lname, address, city, state, dob, dob2, email, phone1, phone2, gender, ntrp, zip, lid, playsocially, phonenotes, homecourt, playtimes, isplayer) VALUES('$uid','".$utc_ts."','$used_rebatecode','$fname','$lname','$address','$city','$state','$dob','$dob2','$email','$phone1','$phone2','$gender','$ntrp','$zip','$lid','$playsocially','$phonenotes','$homecourt','$playtimes','$isplayer')",$con); // isplayer default Y // OUR RECORDS mail($chris, "#$uid $fname $lname [$assplay pre-register initial $codetype2]", $premembermessage, $headers); mail($paul, "#$uid $fname $lname [$assplay pre-register initial $codetype2]", $premembermessage, $headers); } // DB rebatecode get rebatecode and email AFTER activation so code can't be used without confirmed membership //$registrationcomplete = true; $_SESSION['joined']=$email; $rc = array($uid,$email,$isplayer,$rebatesum,$codetype,$promoname,$promobusinessname,$md5email); $_SESSION['registrationcomplete'] = $rc; } $debug .= "**RELOAD PAGE**
"; //<<<<<<<<<<<<<<<<<<<<<<<<<<<< $_SESSION['debug'] = $debug; header("Location:http://go2tennisladder.com/".$p, true, 303); exit(); $debug .= "Detta skall inte synas
"; } elseif($mailaboutmissingzip){ // MAIL US IF ZIP CODE MISSING mail($chris, "Missing Zip: $zip for $fname $lname", "Zip $zip missing for\n".$premembermessage, $headers); mail($paul, "Missing Zip: $zip for $fname $lname", "Zip $zip missing for\n".$premembermessage, $headers); } } else $freshpage = true; /** #################### END CHECK FORM DATA #################### */ ?> Go2TennisLadder - #1 Tennis Ladder in USA