Need help immediately, automatic referral system!!!!

Results 1 to 20 of 20
  1. #1
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    sad Need help immediately, automatic referral system!!!!

    I have a referral system which im trying to setup properly but have been working on it for 2 days straight now and cant find a solution, help will be greatly appreciated, all PHP files will be below. Thanks in advance!

    When I click on a referral link, it redirects me to the register page, I then sign up and sometimes it will redirect to the me.php page and sometimes it will freeze with white screen on register_submit.php, but the problem is it dosnt update the database with the referral points so i can sign up using a referral link and it wont add the referral point to my account.

    r.php (This processes the link before redirecting to the register page, example referral link, http://habbz.servequake.com/r.php?user=Test)

    PHP Code:
    <?php/* #################################################################### \||                                                                     |||| TwinkieCMS - Use of this software is strictly prohibited.           *#|| # Copyright (C) 2014 lD@vidl.                                       *#||---------------------------------------------------------------------*#||---------------------------------------------------------------------*#|| Script pensado para la gestión de retroservers Habbo.               *#|| Tanto el script como los autores del mismo no tienen ningún tipo    *#|| de asociación con Habbo y/o Sulake Oy Corp. Por lo tanto, estos no  *#|| se hacen responsables del uso que el usuario le dé.                 *#||                                                                     ||\ ################################################################### */ob_start();    require_once 'inc/core.php';        $user->logged('no');
        function 
    base58_decode($num) {        $alphabet '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';        $len strlen($num);        $decoded 0;        $multi 1;             for ($i $len 1$i >= 0$i--) {            $decoded += $multi strpos($alphabet$num[$i]);            $multi $multi strlen($alphabet);        }             return $decoded;    }    $remote_ip USER_IP;    $sql $db->query("SELECT * FROM users WHERE ip_last = '".$remote_ip."'");
        if(
    $sql->num_rows 0) {        header("Location: " PATH "/register.php");        exit;    } else {        if (isset($_GET['id'])){            $decoded base58_decode($_GET['id']) or die(header("Location: "PATH ."/"));                    $_SESSION['refer'] = $user->filtertext($decoded);            $_SESSION['refer_type'] = "id";        }        if (isset($_GET['user'])){                $_SESSION['refer'] = $user->filtertext($_GET['user']);            $_SESSION['refer_type'] = "username";        }        header("Location: "PATH ."/register.php");        exit;    }ob_end_flush(); ?>
    register_submit.php (Redirects to me page after registering)

    PHP Code:
    <?php/* #################################################################### \||                                                                     |||| TwinkieCMS - Use of this software is strictly prohibited.           *#|| # Copyright (C) 2014 lD@vidl.                                       *#||---------------------------------------------------------------------*#||---------------------------------------------------------------------*#|| Script pensado para la gestión de retroservers Habbo.               *#|| Tanto el script como los autores del mismo no tienen ningún tipo    *#|| de asociación con Habbo y/o Sulake Oy Corp. Por lo tanto, estos no  *#|| se hacen responsables del uso que el usuario le dé.                 *#||                                                                     ||\ ################################################################### */ob_start();    require_once 'inc/core.php';        if($user->register_now())    {        header("Location: ".PATH."/me.php");        exit;    }    else    {            header("Location: ".PATH."/register.php?username=".$_POST['reg_username']."&rememberme=false&focus=login-username&login-password");            exit;    }ob_end_flush(); ?>
    Part of functions.php (Rewards the referral with a refer point)

    PHP Code:
    }else{                    $password3 $this->HoloHash($password$user);                    $this->AddUser($user$mail$password3''''$avatarimage);                    $_SESSION['username'] = $user;                    $_SESSION['password'] = $password3;                    if(!empty($_SESSION['refer'])){                        $execute $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");                    }                    header("LOCATION: "PATH ."/me.php");                    return true;                } 
    If you want to have a closer look at these files I will provide the download link for the CMS.

    Cms: https://mega.co.nz/#!tYAFTaLK!BdhgYh...Bcf04-vC9-t5IU

    Please help me find the solution to fix the problem, Thank You!!!!


  2. #2
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Replace this:

    PHP Code:
    $execute $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1"); 
    To:

    PHP Code:
    $execute $db->query("UPDATE users SET refer_count = refer_count + 1 WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1"); 
    Didn't test it, I can provide you another solution if this one doesn't work

  3. #3
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    No that doesnt work as ive already tried that, I know the query is correct because I copied the query and changed .$this->filtertext($_SESSION['refer']). to my username and pasted it in phpmyadmin and it added 1 referral point to my username.

    Thanks for the reply!

  4. #4
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    No that doesnt work as ive already tried that, I know the query is correct because I copied the query and changed .$this->filtertext($_SESSION['refer']). to my username and pasted it in phpmyadmin and it added 1 referral point to my username.

    Thanks for the reply!
    Simply display the $_SESSION and find out if it's catching the name correctly

    PHP Code:
    echo $_SESSION['refer']; 

  5. #5
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    I put the echo on the register_submit.php page and it displayed my username so thats working, what happens tho is if you click a referral link and then register it will freeze with white screen on register submit page until you refresh the page, then it will redirect to me page but doesnt add referral point.

    It will only freeze on register submit if you have clicked a referral link until you refresh the page.

  6. #6
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    I put the echo on the register_submit.php page and it displayed my username so thats working, what happens tho is if you click a referral link and then register it will freeze with white screen on register submit page until you refresh the page, then it will redirect to me page but doesnt add referral point.

    It will only freeze on register submit if you have clicked a referral link until you refresh the page.
    Sorry, I've been out for GYM

    Well, so the issue is with the $_POST thing in register_submit... can you paste it on pastebin? Is better to visualize the code xD

  7. #7
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    register_submit.php

    http://pastebin.com/dANsHhdu

    I think its something to do with this code:

    if(!empty($_SESSION['refer'])){
    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
    }
    header("LOCATION: ". PATH ."/me.php");
    return true;

    or this code:

    if(!empty($_SESSION['refer'])){
    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
    }
    header("LOCATION: ". PATH ."/me.php");
    return true;
    Last edited by Habbz96; 02-02-15 at 10:23 PM.

  8. #8
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    register_submit.php

    http://pastebin.com/dANsHhdu
    Sorry, I forgot to ask you the other files, can you paste them as well in pastebin?

  9. #9
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    functions.php: http://pastebin.com/5eN1ZMC8

    r.php: http://pastebin.com/9drApFDJ (What im aware of I dont think the problem is with r.php as it seems to do its job fine but I cant be certain)

  10. #10
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    functions.php: http://pastebin.com/5eN1ZMC8

    r.php: http://pastebin.com/9drApFDJ (What im aware of I dont think the problem is with r.php as it seems to do its job fine but I cant be certain)
    Can you tell me the full path til he actual register? For instance:

    User clicks some sort of link in link.php and then gets redirected to register.php, as soon as he fill the fields and click the form button, page gets blank

  11. #11
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    Yeh for example, user clicks http://habbz.servequake.com/r.php?user=Alex then gets redirected to http://habbz.servequake.com/register.php then after filling out register and submitting the form they get redirected to http://habbz.servequake.com/register_submit.php then that redirects instantly or should do to http://habbz.servequake.com/me.php but in my case if a user signs up by clicking a referral point it freezes on a white screen at http://habbz.servequake.com/register_submit.php untill you refresh the page then it redirects to http://habbz.servequake.com/me.php but doesnt reward referral point other than that if they sign up without clicking referral link it seems to work fine.

    Thanks for your help, greatly appreciated!!!!

  12. #12
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    Yeh for example, user clicks http://habbz.servequake.com/r.php?user=Alex then gets redirected to http://habbz.servequake.com/register.php then after filling out register and submitting the form they get redirected to http://habbz.servequake.com/register_submit.php then that redirects instantly or should do to http://habbz.servequake.com/me.php but in my case if a user signs up by clicking a referral point it freezes on a white screen at http://habbz.servequake.com/register_submit.php untill you refresh the page then it redirects to http://habbz.servequake.com/me.php but doesnt reward referral point other than that if they sign up without clicking referral link it seems to work fine.

    Thanks for your help, greatly appreciated!!!!
    Again, I didn't test it, so this is all about testing, try to replace this (register_submit.php):

    PHP Code:
     if($user->register_now()) 
    To:

    PHP Code:
     if($user->register_now() == true

  13. #13
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    That didnt work, does exactly the same thing and freezes with white screen on register_submit.php.

  14. #14
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    PHP Code:
    <?php/* #################################################################### \||                                                                     |||| TwinkieCMS - Use of this software is strictly prohibited.           *#|| # Copyright (C) 2014 lD@vidl.                                       *#||---------------------------------------------------------------------*#||---------------------------------------------------------------------*#|| Script pensado para la gestión de retroservers Habbo.               *#|| Tanto el script como los autores del mismo no tienen ningún tipo    *#|| de asociación con Habbo y/o Sulake Oy Corp. Por lo tanto, estos no  *#|| se hacen responsables del uso que el usuario le dé.                 *#||                                                                     ||\ ################################################################### */ob_start();        require_once 'inc/core.php';               if($user->register_now())        {                echo "This would work";        }        else        {                        echo "This wouldn't work";        }ob_end_flush(); ?>
    Replace your register_submit.php to this, what does it displays?

  15. #15
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    It just displays:

    register_now()) { echo "This would work"; } else { echo "This wouldn't work"; }ob_end_flush(); ?>

    could u try pasting it in pastebin so its formatted correctly.

  16. #16
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    It just displays:

    register_now()) { echo "This would work"; } else { echo "This wouldn't work"; }ob_end_flush(); ?>

    could u try pasting it in pastebin so its formatted correctly.
    There you have it: http://pastebin.com/krHbwJUY

  17. #17
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    It displays a blank white page but when I reload the page it displays "This would not work"

    It also adds the registered user to the database.

  18. #18
    Member mateuscm is offline
    MemberRank
    Jul 2014 Join Date
    94Posts

    Re: Need help immediately, automatic referral system!!!!

    Quote Originally Posted by Habbz96 View Post
    It displays a blank white page but when I reload the page it displays "This would not work"

    It also adds the registered user to the database.
    Try removing those ob_start and ob_flush lines

  19. #19
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    Does exactly the same with or without those lines.

    - - - Updated - - -

    I think the problem is something to do with this code:

    if(!empty($_SESSION['refer'])){
    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
    }
    header("LOCATION: ". PATH ."/me.php");
    return true;

    or this code:

    if(!empty($_SESSION['refer'])){
    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");
    }
    header("LOCATION: ". PATH ."/me.php");
    return true;

  20. #20
    Member Habbz96 is offline
    MemberRank
    Jan 2015 Join Date
    BristolLocation
    71Posts

    Re: Need help immediately, automatic referral system!!!!

    Ok so ive done a bit more testing and im pretty certain that the error im getting is to do with the following code:

    $execute = $db->query("UPDATE users SET refer_count = refer_count + '1' WHERE username = '".$this->filtertext($_SESSION['refer'])."' LIMIT 1");

    When I remove the code in red from the code above and change it to mysql_query, it doesn't freeze on the register_submit.php but it also doesn't reward referral point.

    It could also be the following code:

    if(!empty($_SESSION['refer'])){

    I tried changing this to numerous things without luck such as: if(!isset($_SESSION['refer'])){

    Please help as ive been trying to get this to work for 3 days straight now, willing to make you administrator/manager on my hotel when its live if you help me solve this problem. Thank you!

    - - - Updated - - -

    I just forced PHP to show me the errors and it displayed this:

    Notice: Undefined variable: db in C:\xampp\htdocs\inc\functions.php on line 438

    Fatal error: Call to a member function query() on null in C:\xampp\htdocs\inc\functions.php on line 438


    - - - Updated - - -

    Thread continued here: http://forum.ragezone.com/f333/help-referral-system-errors-1050313/



Advertisement