PHP Classes

File: Tutorial

Recommend this page to a friend!
  Classes of abdulmalik abdulrrahman   Members Controller   Tutorial   Download  
File: Tutorial
Role: Documentation
Content type: text/plain
Description: Tutorial
Class: Members Controller
Manage records of registered users in a MySQL
Author: By
Last change:
Date: 12 years ago
Size: 3,814 bytes
 

Contents

Class file image Download
Function addfieldsname: Use this function to enter the field names for the table that will deal with Class Function adduserinfo4register: Use this function to add data to fields for registration Function register_member it used for register member after using adduserinfo4register Function login: it used to login a member Function check_member: see if the visitor are logined in or not Function permission: get the permission of the member Function print_errors_reports: see the errors the happened to class Function get_userinfo_byid: to get user info by id Function get_userinfo_byusername: to get user info by username Function get_userinfo_byemail: to get user info by email Function get_userinfo_byfldname: to get user info by your extra fldname Function edit_member: to edit member info Function delete_member: to delete member Function logout: to logout the logined member example to register a member: <? // make sure you are connected to database $conn = mysql_connect("localhost","root",""); mysql_select_db("test",$conn); $memCont = new membersControler; $memCont->adduserinfo4register(""); //id $memCont->adduserinfo4register("membersControler"); // username $memCont->adduserinfo4register(md5("pass")); //password $memCont->adduserinfo4register("email@hotmail.com"); //email $memCont->adduserinfo4register("admin"); // permission // if there is an extra field in members table add $memCont->adduserinfo4register with its value $memCont->register_member(); // do register ?> example for getting info of any user: <? // make sure you are connected to database $conn = mysql_connect("localhost","root",""); mysql_select_db("test",$conn); $memCont = new membersControler; // make sure you add fields name before you get info $memCont->addfieldsname("your_id_field","your_user_field","your_password_field","your_email_field","your_permission_field"); $info = $memCont->get_userinfo_byid("1"); // id print_r($info); $info2 = $memCont->get_userinfo_byusername("membersControler"); // username print_r($info2); $info3 = $memCont->get_userinfo_byemail("email@hotmail.com"); //email print_r($info3); $info4 = $memCont->get_userinfo_byfldname("your_fieldname","value","0"); //if you have an extra fieldĄthe third parameter use to know you want the rows is equal value make it 0 or less than make it -1 or more than make it 1 print_r($info4); ?> example to login, logout and check_member: <? // make sure you are connected to database $conn = mysql_connect("localhost","root",""); mysql_select_db("test",$conn); $memCont = new membersControler; // make sure you add fields name before you get info $memCont->addfieldsname("your_id_field","your_user_field","your_password_field","your_email_field","your_permission_field"); $memCont->login("membersControler",md5("pass"); if($memCont->check_member()){ echo "Hi, user"; } else { echo "invalid username and password"; } $memCont->logout(); if(!$memCont->check_member()){ echo "bye!"; } ?> example for edit or delete member: <? / make sure you are connected to database $conn = mysql_connect("localhost","root",""); mysql_select_db("test",$conn); $memCont = new membersControler; // make sure you add fields name before you get info $memCont->addfieldsname("your_id_field","your_user_field","your_password_field","your_email_field","your_permission_field"); $id = "id of member to edit"; $memCont->edit_member($id,"new value","field to edit");// edit print_r($memCont->get_userinfo_byid($id)); $memCont->delete_member("id to delete"); ?> if your script doesn't work just like you want it so type this on end of script "$memCont->print_error_reports" and will print errors on your browser