Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with ref links

    Basically, I need to build a referral link/URL that puts the referral name in the referral box at the registration page. I'm new to PHP, so I hope you understand

    PHP Code:
    <?php
    $ref_title 
    "Register Free";
    if(
    $set['recaptcha_enabled'])
    {
    require_once(
    'modules/recaptcha/recaptchalib.php');
    }

    $tok_id sha1(md5(session_id()));

    if(
    $_COOKIE['tref'])
    {
    $ref $_COOKIE['tref'];
    } else {
    $ref $do->get_r_file_url();
    $ref str_replace(array(".html""/"), ""$ref);
    if(
    eregi('.php'$ref)) { $ref=false; }

    setcookie("tref"$reftime()+60*300);
    }

    if(
    $loggedin)
    {
    $error "You are already logged in.";
    $show_login=0;
    } elseif(
    $_POST)
    {
    $username $do->filter($_POST[1]);
    $password $do->filter($_POST[2]);
    $confirm_password $do->filter($_POST[3]);
    $email $do->filter($_POST[4]);
    $alertpay $do->filter($_POST[5]);
    $referral $do->filter($_POST[6]);
    $country $do->filter($_POST[7]);

    if(
    $referral != "") {
    $sql mysql_query("SELECT * FROM users WHERE username='{$referral}'");
    $sql mysql_fetch_array($sql);
    $membership $sql['upgname'];
    $drefs mysql_query("SELECT * FROM users WHERE upline='{$referral}' AND uplinetype<2");
    $drefs mysql_num_rows($drefs);
    $mbrshp mysql_query("SELECT dreflimit FROM upg_options WHERE uo_name='{$membership}'");
    $mbrshp mysql_fetch_array($mbrshp);
    $dreflimit $mbrshp['dreflimit'];

    if(
    $membership == "Standard") {
        
    $dreflimit $set['stddreflimit'];
    }
    }

    if(
    $set['recaptcha_enabled'])
    {
    # the response from reCAPTCHA
    $resp null;
    # the error code from reCAPTCHA, if any
    $error null;

    # was there a reCAPTCHA response?
    if ($_POST["recaptcha_response_field"]) {
            
    $resp recaptcha_check_answer ($set['recaptcha_privatekey'],
                                            
    $_SERVER["REMOTE_ADDR"],
                                            
    $_POST["recaptcha_challenge_field"],
                                            
    $_POST["recaptcha_response_field"]);

            if (!
    $resp->is_valid) {
    $error=(!$error) ? "You entered an invalid captcha code." $error;
    $show_login=1;
            }
    } else {
    $error=(!$error) ? "You entered an invalid captcha code." $error;
    $show_login=1;
    }


    if(
    $_POST["token"] !=$tok_id)
    {
    $error "Your token session has expired, please re-enter this form again to continue.";
    $show_page 1;
    }
    if(!
    $username)
    {
    $error "You forgot to fill in your username.";
    $show_page 1;
    }
    if(!
    $password)
    {
    $error = (!$error) ? "You forgot to fill in your password." $error;
    $show_page 1;
    }
    if(!
    $confirm_password)
    {
    $error = (!$error) ? "You forgot to fill in your password again." $error;
    $show_page 1;
    }
    if(!
    $email)
    {
    $error = (!$error) ? "You forgot to fill in your email." $error;
    $show_page 1;
    }
    if(!
    $alertpay)
    {
    $error = (!$error) ? "You forgot to fill in your payment email." $error;
    $show_page 1;
    }
    if(
    $password != $confirm_password)
    {
    $error = (!$error) ? "Your passwords don't match, try again." $error;
    $show_page 1;
    }
    if(
    strlen($password) < 6)
    {
    $error = (!$error) ? "Your password must be at least 6 characters." $error;
    $show_page 1;
    }
    if(
    strlen($username) < 3)
    {
    $error = (!$error) ? "Your username must be at least 3 characters." $error;
    $show_page 1;
    }
    if(
    strlen($username) > 16)
    {
    $error = (!$error) ? "Your username cannot exceed 16 characters." $error;
    $show_page 1;
    }
    if(!
    eregi('@'$email) or !eregi('.'$email))
    {
    $error = (!$error) ? "Your email address is invalid, try again." $error;
    $show_page 1;
    }
    if(!
    eregi('@'$alertpay) or !eregi('.'$alertpay))
    {
    $error = (!$error) ? "Your payment email address is invalid, try again." $error;
    $show_page 1;
    }
    $test "abcdefghijklmnopqrstuvwxyz123456789";
    $text =  str_split($password);
    for(
    $i=0;$i<strlen($password);$i++) {    
        if(
    strpos($teststrtolower($text[$i])) <= && strtolower($text[$i]) != "a") {
            
    $err 1;
        }
    }
    if(
    $err) {
    $error = (!$error) ? "Your password must be alphanumeric characters A-Z and/or 0-9." $error;
    $show_page 1;
    }    
    if(
    $do->request_exceed($gc))
    {
    $error = (!$error) ? "Only one request every 30 seconds, next request in ".($do->show_request_left($gc))." seconds." $error;
    $show_page 1;
    } else {
    $do->start_request_control($gc);
    }
    if(
    $referral != "") {
    if(
    $drefs >= $dreflimit)
    {
        
    $error = (!$error) ? "I'm sorry, this user has reached his/her direct referral limit. Please either register under a different upline or register under no upline." $error;
        
    $show_page 1;
    }
    }
    if(!
    $error)
    {
    $pq mysql_query("SELECT COUNT(*) AS cnt FROM users WHERE username='$username' OR email='$email' LIMIT 1;");
    $pq mysql_fetch_array($pq);
    $pq $pq['cnt'];

    if(
    $pq)
    {
    $error = (!$error) ? "Your username and/or email is already in use, please pick another." $error;
    $show_page 1;
    }


    $pq2 mysql_query("SELECT COUNT(*) AS cnt FROM users WHERE lastip='{$_SERVER['REMOTE_ADDR']}' LIMIT 1;");
    $pq2 mysql_fetch_array($pq2);
    $pq2 $pq2['cnt'];

    if(
    $pq2)
    {
    $error = (!$error) ? "You're IP is already being used so you're not permitted to signup again." $error;
    $show_page 1;
    }

    if(
    strlen($referral) > 1)
    {
    $refex mysql_query("SELECT COUNT(*) AS cnt FROM users WHERE username='$referral' LIMIT 1;");
    $refex mysql_fetch_array($refex);
    $refex $refex['cnt'];

    if(!
    $refex)
    {
    $error = (!$error) ? "A user with that referral name doesn't currently exist." $error;
    $show_page 1;
    }
    }
    }
    if(
    $set['pcaptcha']) {
    if( 
    strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){ 
    $error=(!$error) ? "You entered an invalid captcha." $error;
    $show_page 1;
    }
    }
    if(!
    $error)
    {
    $encoded_password sha1($password);

    if(
    $do->new_user($username$encoded_password$email$alertpay$referral$country$c))
    {
    $contents .= "    <div id='box2'>
            <div id='lb'>
                <div id='rb'>
                    <div id='bb'>
                        <div id='blc'>
                            <div id='brc'>
                                <div id='tb'>
                                    <div id='tlc'>
                                        <div id='trc'>        
                                            <div id='content'><h3>Congratulations</h3>
    <p>Your newly created account has been made and you are free to login into your account at any time.</p>
    <p>When logging into your account you can read our Getting Started guide.</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>"
    ;
    mysql_query("INSERT INTO history (username,type,time,custom1,custom2,custom3,custom4,custom5) VALUES ('{$username}','joined',unix_timestamp(),'0','0','0','0','0')") or die(mysql_error());
    mysql_query("UPDATE stats SET users = users + '1'");
    $show_page=0;
    } else {
    $error = (!$error) ? "There was a problem creating your account, please contact the administrator to resolve the problem." $error;
    $show_page 1;
    }

    }

    } else {
    $show_page 1;
    }

    if(
    $error)
    {
    $contents .= "<div class='err'>$error</div>";
    }
    if(
    $show_page)
    {
    if(
    $set['recaptcha_enabled'])
    {
    $recaptcha recaptcha_get_html($set['recaptcha_publickey'], $error);
    }
    if(!
    $ref) { $ref=$_POST[6]; }

    $ip $_SERVER['REMOTE_ADDR'];
    $ip_number sprintf("%u"ip2long($ip));

    $country_query  "SELECT cntry,country FROM ip2country WHERE ip_from<=$ip_number AND ip_to>=$ip_number";

    $country_exec mysql_query($country_query);

    $ccode_array=mysql_fetch_array($country_exec);

    $country_code=$ccode_array['cntry'];

    $country_name=$ccode_array['country'];

    $contents .= "
        <div id='box9'>
            <div id='lb'>
                <div id='rb'>
                    <div id='bb'>
                        <div id='blc'>
                            <div id='brc'>
                                <div id='tb'>
                                    <div id='tlc'>
                                        <div id='trc'>        
                                            <div id='content'>
    <table>
        <tr>"
    ;
        if(
    $ref) {
            
    $contents .= "<td><img src='../themes/GeN3/images/newdref.png' align='center'></td>";
        }else{
            
    $contents .= "<td><img src='themes/GeN3/images/newdref.png' align='center'></td>";
        }
        
    $contents .= "<td><h3><font color='black'>Register</font></h3></td>
        </tr>
    </table>
    <br /><br />
    <form method='post'>
    <input type='hidden' name='token' value='{$tok_id}'>
    <table>
        <tr>
            <td>Username:</td>
            <td><input type='text' name='1' id='username' value='{$username}' class='input'></label></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input id='password' type='password' name='2' value='' class='input'></td>
        </tr>
        <tr>
            <td colspan='2'><small>Your password must be alphanumeric characters A-Z and/or 0-9.</small></td>
        </tr>
        <tr>
            <td>Confirm Password:</td>
            <td><input id='cpassword' type='password' name='3' value='' class='input'></td>
        </tr>
        <tr>
            <td>Email Address:</td>
            <td><input id='email' type='text' name='4' value='{$email}' class='input'></td>
        </tr>
        <tr>
            <td>Alertpay Address:</td>
            <td><input id='alertpay' type='text' name='5' value='{$alertpay}' class='input'></td>
        </tr>
        <tr>
            <td>Referral (optional):</td>
            <td><input id='referral' type='text' name='6' value='{$referral}' class='input'></td>
        </tr>
        <tr>
            <td>Detected Country:</td>
            <td>{$country_name}</td>
        </tr>"
    ;
    if(
    $set['pcaptcha']) {
    $contents .= "
    <tr><td>&nbsp;</td></tr>
    <tr>
        <td colspan='2' align='center'>
            <table style='border-top: 1px solid #000000; border-bottom: 1px solid #000000;'>
                <tr>
                    <td>Type the letters you see below:</td>
                </tr>
                <tr>"
    ;
    if(
    $ref) {
            
    $contents .= "<td><img src='../image.php?$res' /></td>";
        }else {
            
    $contents .= "<td><img src='image.php?$res' /></td>";
        }
    }
    $contents .="<td><input type='text' size='3' maxlength='3' name='code' autocomplete='off' class='securitycode' value=''></td></tr></table></tr>";
    if(
    $set['recaptcha_enabled']) {
    $contents .= "
    <tr>
        <td colspan='2'>{$recaptcha}</td>
    </tr>"
    ;
    }
    $contents .= "
    <input type='hidden' name='7' value='{$country_name}'>
    <tr>
        <td align='center'><br /><br /><input type='submit' value='Register Account'></td>
    </tr>
    </form>
    </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>"
    ;

    }
    ?>
    PHP Code:
    <tr>
            <
    td>Referral (optional):</td>
            <
    td><input id='referral' type='text' name='6' value='{$referral}' class='input'></td>
        </
    tr
    Last edited by Bfghost; 01-29-2010 at 04:10 PM.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    It appears to already be finished. What are you asking?
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What I want is to have a URL that looks like http://.../register.php/?ref=xxxxx where xxxxx automatically is inserted into the referral box on the registration page. What I don't know is how the URL ending part (e.g. ?ref=xxxx) should be formatted for the xxxx part to be automatically pasted into the referral box, and if any changes have to be made in the code for it to be possible.
    Last edited by Bfghost; 01-29-2010 at 06:31 PM.

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Ok you use a GET function for that. Here is what you use at the top of your script.

    PHP Code:
    if (isset($_GET["ref"])) {
        
    $ref explode(":",$_GET["ref"]);

        switch(
    $ref[0])
        {
            case 
    'referral':
                
    referral($ref[0]);
            break;

     }

    That would give you www.website.com/register.php?ref=referral

    Now you need to use an ID to keep the value. Such as this.

    PHP Code:
    function referral($id) { 
    That would then turn it into something like this.
    www.website.com/register.php?ref=referral:19384
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #5
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Where should I put the
    PHP Code:
    function referral($id) { 
    part?

  • #6
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Is it going to be linked to some other website not owned by you? Or people just type in their referral link?

    Also why do you open like 12 DIV tags and close them multiple times in the script? Why not use 2 or 3 tops?
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #7
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's a ptc site, so people will type in their referral link.
    Let's say a user wants to register with person xx as his referral. Then the link would look something like this: http://..../register.php?ref=xx.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •