PHP PROJECT

README.md

MLM Binary Tree

This class can build a multi-level marketing tree from member forms. It can generate HTML for forms to login or register a new user to create or update the profile data of members that will form a MLM binary tree. The class can display the hierarchy of MLM member nodes with links to update or delete members. The member profiles are stored in a MySQL database accessed using MySQLi.

Files


NameTypeSizeLast Modified
config.php phpfile icon 81 24 April 2017 08:52:10
mlmtree3.php phpfile icon 26407 22 February 2016 11:40:46
sql.sql sqlfile icon 1034 22 February 2016 11:40:46
example.php phpfile icon 3295 24 April 2017 08:52:16
template directory icon 4096 31 March 2017 08:37:28

Source

Demo

You can find a demo available here: mlm binary tree

Requirment

  • mySql
  • PHP >= 5.4
  • Apache Server

Contribute

  • Vishv Sahdev

Example

  1. <?
  2. session_start();
  3. define("APP_FOLDER",__DIR__ ."/");
  4. include APP_FOLDER ."config.php";
  5. include APP_FOLDER "mlmtree3.php"// class file
  6. //-------------------------Database Init
  7. if($_SERVER['REMOTE_ADDR'] == '::1' || $_SERVER['REMOTE_ADDR'] == '127.0.0.1' )
  8. $mlm= new newmlmtree('localhost',$user,$password,$dbname) ;
  9. else
  10. $mlm= new newmlmtree('localhost',$user,$password,$dbname) ;
  11. $op=array();
  12. //---------------------------Left Bar
  13. if($mlm->_lc()){
  14. $op['leftcontent'] = '<li class="list-group-item"><a href="?q='.$mlm->encode('q=showtree').'" >Binary Tree</a></li>';
  15. $op['leftcontent'] .= '<li class="list-group-item"><a href="?q='.$mlm->encode('q=profile').'" >Profile</a></li>';
  16. $op['leftcontent'] .= '<li class="list-group-item"><a href="?q='.$mlm->encode('q=logout').'" >LogOUT</a></li>';
  17. $lc=true;
  18. $op['maincontent']='<div class="alert alert-success" role="alert">Welcome Member Area !</div>';
  19. }
  20. else
  21. {
  22. $lc=false;
  23. $op['leftcontent']='<li class="list-group-item"><a href="?q='.$mlm->encode('q=login').'" >LogIN</a></li>';
  24. $op['leftcontent'] .= '<li class="list-group-item"><a href="?q='.$mlm->encode('q=newmember').'" >New Member</a></li>';
  25. $op['maincontent']='<div class="alert alert-warning" role="alert">Welcome!</div>';
  26. }
  27. //-------------------------Query 
  28. if(isset($_GET['q'])){
  29. $ps=$mlm->decode($_GET['q']); 
  30. if(mb_detect_encoding($ps'UTF-8'true))
  31. parse_str($ps);
  32. else
  33. $op['maincontent'] .= '<div class="alert alert-info" role="alert">404 File Not Found</div>';
  34. }
  35. //--------------route------------------------------
  36. if(isset($_POST['ok']) && $_POST['ok'] == 'New Member')
  37. $op['maincontent'] .= $mlm->_newMember($_POST,$mlm->tablemlm);
  38. elseif(isset($_POST['ok']) && $_POST['ok'] == 'Profile')
  39. $op['maincontent'] .= $mlm->_profile($_POST,$mlm->tablereg);
  40. elseif(isset($_POST['ok']) && $_POST['ok'] == 'Update')
  41. $op['maincontent'] .= $mlm->_updateMember($_POST);
  42. elseif(isset($_POST['ok']) && $_POST['ok'] == 'Delete')
  43. $op['maincontent'] .= $mlm->_DeleteMember($_POST);
  44. elseif(isset($_POST['ok']) && $_POST['ok'] == 'Login')
  45. $op['maincontent'] .= $mlm->_login($_POST,$mlm->tablemlm);
  46. elseif(isset($q) && $q == 'newmember')
  47. {
  48. $op['maincontent'] .= $mlm->newMember(isset($_POST) ? $_POST '' );
  49. }
  50. elseif(isset($q) && $q == 'showtree' && $lc)
  51. {
  52.     if(isset($add)){
  53.     $_POST['remail']=$add;
  54.     $op['maincontent'] .= $mlm->newMember(isset($_POST) ? $_POST '' );
  55.     }
  56.     elseif(isset($edit)){
  57.         $r=$mlm->fpid($edit,'Update');
  58.     $op['maincontent'] .= $mlm->newMemberUPdate(!empty($r) ? $r '' );
  59.     }
  60.     elseif(isset($del)){
  61.             $r=$mlm->fpid($del,'Delete');
  62.     $op['maincontent'] .= $mlm->newMember(!empty($r) ? $r '' );
  63.     }
  64.     
  65.     
  66. $op['footer'] = isset($email) ? $mlm->showtree($email) : $mlm->showtree();
  67. $op['maincontent'] .="<div id='chart_div'>";
  68. }
  69. elseif(isset($q) && $q == 'login')
  70. {
  71. $op['maincontent'] .= $mlm->login(isset($_POST) ? $_POST '' );
  72. }
  73. elseif(isset($q) && $q == 'profile' && $lc)
  74. {
  75. $op['maincontent'] .= $mlm->profile(isset($_POST) ? $_POST '' );
  76. }
  77. elseif(isset($q) && $q == 'logout' && $lc)
  78. {
  79. $op['maincontent'] .= $mlm->logout();
  80. }
  81. //---------------------------------------------
  82. //echo APP_FOLDER ."template/form-template.html";
  83. if(is_file(APP_FOLDER ."template/form-template.html")){
  84.             echo $mlm->render_temp(APP_FOLDER ."template/form-template.html",$op);
  85.     }    

>>

Download