Page 1 of 1

Group tutorials

Posted: Mon Oct 20, 2008 3:20 am
by phpserver
Hi everyone,i have been looking for a tutorial that explains how i would make a group(similar to facebook,myspace,yahoo or google) where i can allow members to form their own groups leave or join a group.If any one has a tutorial or knows where i can get one,post a link or the tutorial itself.Thank you.

Re: Group tutorials

Posted: Mon Oct 20, 2008 9:58 am
by panic!
You want to know how to make a site similar to facebook or google?

Maybe you could rephrase the question.

Re: Group tutorials

Posted: Mon Oct 20, 2008 10:09 am
by aceconcepts
I don't know if there is a particular script available for you, however, you could look into relational databases.

Re: Group tutorials

Posted: Tue Oct 21, 2008 7:24 am
by phpserver
panic! wrote:You want to know how to make a site similar to facebook or google?

Maybe you could rephrase the question.
No i dont want to make a new facebook or myspace.For instance on facebook,there are groups people join and i am sure if you have a facebook account you have been invited to join groups too,question is,are there tutorials explaining how you would code a group from top to bottom using php and mysql.

Re: Group tutorials

Posted: Tue Oct 21, 2008 7:37 am
by yoji
I don't think there will be a plain script available out there on internet. You see it is not that simple. You make such a site by combining multiple scripts. Plus people make tons of money once they finish making such a project. Walk the stairs; learn step by step and eventually you might just make such a thing. The reason one of the guys made fun of you is because the question you asked is really huge... It's like going to a doctor and asking him to move his wand so that you may be treated. :P

Re: Group tutorials

Posted: Tue Oct 21, 2008 8:01 am
by aceconcepts
Before you even attempt a project like this or even a much more basic one, you should really research relational databases, normailsation, data types and keys.

Like the others have said, your objective is a large scale one. Know your technologies before turning to tutorials and pre-written scripts.

Re: Group tutorials

Posted: Tue Oct 21, 2008 8:27 am
by phpserver
aceconcepts wrote:Before you even attempt a project like this or even a much more basic one, you should really research relational databases, normailsation, data types and keys.

Like the others have said, your objective is a large scale one. Know your technologies before turning to tutorials and pre-written scripts.
I dont think you understand.Think of it in our everyday situation like mine.I want to make a website to cater for 18 fellow classmates.We are in groups of 6.So i might need to join a different group or form mine but that group shouldn't exceed 6 people(the default).Why is that too hard.Your answer and the past reply puts it like its an impossible thing and should not be attempted,since you reckon a database will be extensively in use,would you care to suggest in the simplest or even in brief of lengths if you may(in pseudo code to make it even easier) how you would code a group and that way i will see what you mean.

I am an experienced php coder and i dont understand why you pick it at random that i go around collecting scripts,i have done a script but i dont think its the best so am seeking to better it,any help you can offer?

Re: Group tutorials

Posted: Tue Oct 21, 2008 8:35 am
by papa
Well first you need to make a db design:

User
id name password email group

Groups
id name


Then I would probably start of with the authentication script so users can log in and out.

After that you need to make a registration and validation script.

Then create, edit, delete groups
Then join groups.

If you want users to be able to join several groups the group field could be serialized for example.

Something like that?

Re: Group tutorials

Posted: Tue Oct 21, 2008 8:42 am
by phpserver
yoji wrote:I don't think there will be a plain script available out there on internet. You see it is not that simple. You make such a site by combining multiple scripts. Plus people make tons of money once they finish making such a project. Walk the stairs; learn step by step and eventually you might just make such a thing. The reason one of the guys made fun of you is because the question you asked is really huge... It's like going to a doctor and asking him to move his wand so that you may be treated. :P
:offtopic:

This is what i have in mind.
1.login
2.view all members
3.view groups
4.navigate to this group[test group]
5.options :::Join group
/***********************************************/
copy this $row containing this info from tablex to tabley
$row = name,email,md5(password),address,last_access_time etc
>>Maybe will make you a member of group abc
to leave the group delete this $row from tabley
Optional parameters should obviously be included.

/***********************************************/
Maybe if you could have been a little more helpful you could have just said you have not come across such a class or kept your not so illuminating analogy to the issue at hand.

Re: Group tutorials

Posted: Tue Oct 21, 2008 9:03 am
by aceconcepts
Hi everyone,i have been looking for a tutorial that explains how i would make a group(similar to facebook,myspace,yahoo or google) where i can allow members to form their own groups leave or join a group.If any one has a tutorial or knows where i can get one,post a link or the tutorial itself.Thank you.
Take a look at your initial post...now think about why people responded the way they have.

In future try explaining your problem along with you aims and objectives. After all, everyone here, is here to help.

Re: Group tutorials

Posted: Tue Oct 21, 2008 9:36 am
by onion2k
papa wrote:If you want users to be able to join several groups the group field could be serialized for example.
Or you could use a many-to-many relationship link table which would be approximately eleventy billion times better. :)

Re: Group tutorials

Posted: Tue Oct 21, 2008 12:38 pm
by papa
onion2k wrote:
papa wrote:If you want users to be able to join several groups the group field could be serialized for example.
Or you could use a many-to-many relationship link table which would be approximately eleventy billion times better. :)
Are you willing to elaborate or maybe give a good url? I'm eager to learn more. PM if it's OT. :)

Re: Group tutorials

Posted: Tue Oct 21, 2008 1:21 pm
by onion2k
papa wrote:
onion2k wrote:
papa wrote:If you want users to be able to join several groups the group field could be serialized for example.
Or you could use a many-to-many relationship link table which would be approximately eleventy billion times better. :)
Are you willing to elaborate or maybe give a good url? I'm eager to learn more. PM if it's OT. :)
Explanation: http://en.wikipedia.org/wiki/Many-to-many_(data_model)
Pretty good tutorial: http://www.tonymarston.net/php-mysql/many-to-many.html

Re: Group tutorials

Posted: Tue Oct 21, 2008 1:25 pm
by papa
onion2k wrote:...
Awesome, thanks!

Re: Group tutorials

Posted: Wed Oct 22, 2008 1:41 am
by phpserver
Are you willing to elaborate or maybe give a good url? I'm eager to learn more. PM if it's OT. :)[/quote]
Explanation: http://en.wikipedia.org/wiki/Many-to-many_(data_model)
Pretty good tutorial: http://www.tonymarston.net/php-mysql/many-to-many.html[/quote]

I thought about what you said and this is what i came up with.I enumed group categories and let the simple task of joining a group be copying the name of a user to the members field of the group table.
This is how i would build my group.Once i have tested the code extensively i will post it,although the enum code that creates dropdown menu on the fly actually works.

Best viewed under -gedit.
<?
First of all you need to register new members and this is how you do it.
/****************************************************************************************/
__________________register.html__________________

post the information below to your register.php(obviously from the form below!)

Names
Email
Password
Confirm password

Register securely
________________________________________________

____________________users.sql___________________
id | names | email | password

Table name::users
________________________________________________

Once the registration is done and the user is registered,redirect the user to groups.php.Contents of groups.php are discussed below.

NB-1:Remeber to store your passwords in md5 format to keep them safe.
/****************************************************************************************/

Secondly you will need groups.sql to store all information about your groups and here are all the necessary fields in groups.sql.

/***********************************************************************************************************/
id | groupname |group descrptn | members | category | registerdate | owner | topictitle | topiccontent | topic replies

Table name::group
NB-2:categories here,are ENUM options and here are the values;{Php,Moto,Python,C,Haskell,Mysql}.
/**********************************************************************************************************************/

As i said,once a user is logged in successfully,he/she will be redirected to groups.php.I beg to explain the reason why that is so.
/**********************************************************************************************************************/
Here is groups.php.
____________________________________________________________________________________________________
Groups | Create Group | Groups I Am A Member Of | LOGOUT

{The Links above should be arranged as tabs for a neat layout}
____________________________________________________________________________________________________

Allow me to elaborate further on this page,there is nothing unorthodox i must point out as of now,come along.For bravity all time sakes,i will start from left where you can find Groups |....| and i will proceed due right to the point where you see ....|LOGOUT.All files in between Groups and LOGOUT are all .php in generic terms.

It is now time to expain each and every file that falls under groups.php as you can visually gather from above.

Groups |

Link id : group.php

group.php ----This link will query users and group(table users to authenticate the user) and group to get and display the
following information.

group name |group descrptn |group category | total number of members | Action
/******************************************************************************/
I would like to explain a point and to do that, you need see the diplay of
group.php.Since groups.sql has six enum options,there will only be six
categories to choose from.Allow me to display 'false' info that is meant to show how
group.php would display these data from the table 'group'.
/******************************************************************************/
group name |group descrptn |group category | total number of members | Action

xxx evil moto 64 Join

NB-3:Moto is the default option under our ENUM options from the group table
_______________________________________________________________________________

Question::----What exactly happens when a user presses the join button?.

Answer::::----This is what happens.First of all,if a user has arrived at this point,we can safely say that we have
established that the user credentials are authentic.What the group.php does is,it writes the names of the
current user to table 'group' under the members field.How does group.php do that?,simple,it pulls the
names
of the user identified by some session id(SID)straight from the users table.

Anti-Duplicate Measures::::----You could use javascript or ajax to disable the Join button above if you have it on good
authority from the SID incharge that indeed the current user is already a member of the group.
______________________________________________________________________________________________________________________
______________________________________________________________________________________________________________________

| Create Group |

Link id : create_group.php

create_group.php----This link will open a web form.This form will ask you to fill in details about the group you want to
create i.e,
_______________________________________________________________________________________________________________________
group name
category
group description
owner

REGISTER GROUP SECURELY

NB-4:You may ask,why do you bother yourself asking logged in members to provide their names while you could have just
pulled their names straight from the database?.I could say my answer is deceptively simple.I fancy that if i allow
my members to excercise creativity by deciding what should be displayed as their owner names, you are likely to get
very creative members.An owner name that says 'noneofyourbiz' is not illegal but sad because at one time or the
other, you might need to display the owner of the group and you dont want some jibe showing up do you?.
_______________________________________________________________________________________________________________________
_______________________________________________________________________________________________________________________

| Groups I Am A Member Of |

Link id : groups_i_have_joined.php

groups_i_have_joined.php----This link will query group table and users table.The users table query is first and its
function is,it ensures that the user is logged in the first place.The second query is made
to the group table to let us know which groups the user in question is a member of and here
is a sample sql code to achieve that:
/***********************************************************************************************/
$result = "select names from group where names=$names";
You will need to tap the $result as an associative array to display the groups i have joined well
/***********************************************************************************************/
________________________________________________________________________________________________________________
NB-5:You can make always pass the $names variable as a global variable to make use of it in instances like this.
________________________________________________________________________________________________________________
/***************************************************************************************/</SELECT></TD></TR>
You could also attach UNJOIN link at the end of every 'group_i have_joined' like this:

Groups I Have Joined Action Category

1.I party harder than Elliot Spitzer UNJOIN Php
2.Hollywood script writers UNJOIN Python
3.Nairobi Night Runners UNJOIN C

Here is what i reckon will go to the UNJOIN link
/**************************************************************************************************/
$result2 = "delete names from group where category = $category and groupname = $groupname";
/**************************************************************************************************/

| Logout |
<>Unset session variables.

I dont know how an advanced version of a group script would look like but i am guessing people using any advanced grouping software use ACL classes extensively to define who has the rights to do what for instance in optioning whether a group is open for membership or members are invited during the making of a group.I am sharing this pseudocode to allow anyone with any good idea on how better i could improve my group script.I thought listing ENUM options could be a problem for some so i wrote this code for anybody interested in testing this simple system.
/**********************************************************************************************************************/
<?
//db.php
$dbhost = 'localhost';
$dbusername = 'phpserver';
$dbuserpassword = 'phpserver';
$default_dbname = 'mysql';
//define all the important parameters above
$MYSQL_ERRNO = '';
$MYSQL_ERROR = '';

function db_connect()
{
global $dbhost,$dbusername,$dbuserpassword,$default_dbname;
global $MYSQL_ERRNO,$MYSQL_ERROR;
//global parameters now 'initialized'
$link_id = mysql_connect($dbhost,$dbusername,$dbuserpassword);
if(!$link_id) {
$MYSQL_ERRNO = 0;
$MYSQL_ERROR = "Connection failed to the host $dbhost";
return 0;
}
else if(empty($dbname) && !mysql_select_db($default_dbname)) {
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
return 0;
}
else return $link_id;
}
//handle error function up next
function sql_error() {
global $MYSQL_ERRNO,$MYSQL_ERROR;

if(empty($MYSQL_ERROR)) {
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();

}
return "$MYSQL_ERRNO: $MYSQL_ERROR";
}
//a section of code i added to handle enum options
function enum_options($field, $link_id) {
$query = "SHOW COLUMNS FROM users LIKE '$field'";
$result = mysql_query($query,$link_id);
$query_data = mysql_fetch_array($result);

if(eregi("('.*')",$query_data["Type"], $match)) {
$enum_str = ereg_replace("'", "", $match[1]);
$enum_options = explode(',', $enum_str);
return $enum_options;
} else return 0;
}
/*************************************************************************************/
To test whether this code works use this code::
//enum_test.php
include "db.php";
$link_id = db_connect();
mysql_select_db("group");
//make a database named group and dump groups.sql and users.sql
$array = enum_options('category',$link_id);
foreach($array as $var) echo $var,"<P>";

/************************************************************************************/
?>
For an absolute beginner,this is how i constructed my drop down menu on the fly.
<?
//create_group.php and anywhere else where a drop down menu or categories is needed
include "db.php";
$link_id = db_connect();
mysql_select_db("group");
$category_array = enum_options('category', $link_id);
mysql_close($link_id);
//note that now the category array holds all categories a user can possibly choose from
<TR>
<TH WIDTH = "32%" NOWRAP>Categories</TH>
<TD WIDTH = "68%"><SELECT NAME="categories" SIZE="1">
for($i=0; $i < count($category_array); $i++) {
if(!isset($category) && $i == 0) {
echo "<OPTION SELECTED VALUE=\"". $category_array[$i] . "\">" . $category_array[$i] . "</OPTION>\n";
}
else if($category == $category_array[$i]) {
echo "<OPTION SELECTED VALUE=\"". $category_array . "\">" . $category_array[$i] . "</OPTION>\n";
}
else {
echo "<OPTION VALUE=\"". $category_array[$i] . "\">" . $category_array[$i] . "</OPTION>\n";
}
}
</SELECT></TD></TR>

?>

___________________________________________________________________________________
It is no longer a miracle for man to walk on water,he must now watch and conserve it
-Anonymous