...

View Full Version : User profiling.



LearningCoder
10-11-2012, 09:35 PM
Now that I have my register, login and reset pass pages completed and working, I want to add a feature to let users create their own profile. I've been reading up about database design and table relationships.

I'm thinking of creating a new table, with fields such as first_name, hobbies, etc etc. I thought about using my 'hash' column (which holds the generated random string to hash pass with) from my members table and create an identical field within the members_profile table to match the correct user. If matched I wanted to insert data into the members_profile table.

Or, when the users registers at the site, and I insert their info to the database, should I update their id and username into the members_profile table as well at the same time, so that I can match it that way for the future potential profiling they may do?

Would this work? And is it really a good way to go about it?

Just looking for advice.

Regards,

LC.

CoolAsCarlito
10-11-2012, 10:11 PM
The only thing you would need is the user_id field. No since adding more than one field that's a shared data. Just one column that is the same in both tables of your user profiles and your users tables. Easy for a one-to-one table relationship. Makes it easy for joining tables as well.

LearningCoder
10-11-2012, 10:41 PM
Thank you,

So what happens if I have 10 members and the 9th members updates their profile first, if using the user id, will that insert their data into the 9th row? And does that affect it in anyway when retrieving the data?

I could potentially have a table which id fields go from say 5,8,10 should those members update their profile.

Regards,

Lc.

CoolAsCarlito
10-11-2012, 10:45 PM
It would not affect it, if done correctly, because just because user 9 updates their data as long as you are passing around or using the user_id you can use it for the WHERE clause in your SQL statement.

LearningCoder
10-11-2012, 10:52 PM
Ok, do I insert their id and username into the member_profile table when I register them or only when they update their profile?

Regards,

Lc.

tangoforce
10-11-2012, 11:40 PM
Thank you,

So what happens if I have 10 members and the 9th members updates their profile first, if using the user id, will that insert their data into the 9th row?

No it won't. It will simply create a new row and insert it there. If user 9 is the very first user to update / create their profile, their record will be the first row in the profile table.

Thats the way mysql works. There is nothing wrong with this. As long as you have the user_id in the profile table you can still find the correct record.



And does that affect it in anyway when retrieving the data?

Not in the slightest. You simply select the data based on the user id NOT the row position.



I could potentially have a table which id fields go from say 5,8,10 should those members update their profile.


Yes indeed you could and this is perfectly normal / nothing wrong with it. Don't forget its only how it looks in phpmyadmin that you're really concerned about here and even that allows you to sort by a column either asc or desc :thumbsup:

Fou-Lu
10-12-2012, 12:44 AM
3 tables. Member, Field, and MemberField.
Assuming you want the same questions available for everyone to (potentially) use. The Field would represent those possible options (hobby, birthday, lets see, favorite colour, etc), the member is well, your member, and MemberField is a correlation between a member, their "field" and their answer.


+---------------+ +---------------------+ +-----------------+
| member | | memberQuestion | | question |
+---------------+ +---------------------+ +-----------------+
| memberID [PK] |>|----o+| memberID [PK][FK] |+o-----|<| questionID [PK] |
| memberName | | questionID [PK][FK] | | name |
| ... | | answer | | ... |
+---------------+ +---------------------+ +-----------------+


Save the columns; use rows to represent the questions as you don't need to create a structural change (or programming one if you do it dynamically) in order to add more questions, remove, or modify them.


BTW I renamed the "field" to question. Field is just way to ambiguous.

LearningCoder
10-12-2012, 11:54 AM
Thank you for that Tango, I will give that a try.

Fou, I don't understand one part of that, which I am glad you posted, because it shows there is a lot more to it than to just go ahead and start creating because I will inevitably run into an issue and come here. I am going to study the table relationship part and see if I can understand a bit more because at the minute I have not much knowledge...

I'm having an issue at the moment with securing my data for insertion......

I am sending my input through the addslashes() function but everytime I do, it adds 3 slashes before the related characters. magic_quotes and magic_quotes_gpc are both off as I would like to escape the data myself..

Anyone know what's going on here? I presumed it might have been the magic quotes thing so I turned them off and it's still happening.

Kind regards

LC.

tangoforce
10-12-2012, 01:35 PM
Fous explanation is pretty much the same thing that I was saying but dressed up in a different way and with a graphical explanation.

PK = Primary Key - The primary key in the table you're looking at.
FK = Foreign Key - The primary key of another table that you're going to select data from

If you look at Fous graphical example, if you wanted to select a users question and answer for their profile you would:

Select the user from the first table by their memberID, then select their answers from the next table by matching the memberID and then finally you would pull the questions to those answers from the next table by matching the questionID.

I would have done it slightly differently having the question itself in the second table and the answers in the third table but it doesn't really matter as its an example.

Also in your case you'd be running 3 select queries however on a busy web server using a shared hosting package that would put more strain on the SQL server. Therefore to reduce 3 queries to one, you'd want to join those tables temporarily in your SQL which is a very cool trick. I shall leave you to google mysql joins :thumbsup:

LearningCoder
10-12-2012, 02:01 PM
Ah ok so when looking at the two memberID columns in the two tables there, they are basically the same thing as me using 'id' in the way which we set it to primary key and also auto-increment?? If that's right, does it also apply for the 3rd table questionID?

Say I do it your way, selecting the member, 'question' then 'answer' tables...

So the first table is the table which I currently have:

members -> id,user,pass,email,join_date,hash,reset??

The second table will contain the questions I ask the users such as:

questions-> id, first_name, gender, hobby, age, etc..??

And the 3rd table contains the answers to those questions:

answers-> id, name,gender, hobby, age etc..?

Is that right?

I will google that shortly... :) ty

Regards,

LC.

Fou-Lu
10-12-2012, 03:37 PM
For your particular tables, I'd do as such:


+---------------+ +---------------------+ +-----------------+
| member | | answer | | question |
+---------------+ +---------------------+ +-----------------+
| id [PK] |>|----o<| memberID [PK][FK] |>o-----|<| id [PK] |
| user | | questionID [PK][FK] | | name |
| pass | | answer | | description |
| email | +---------------------+ | required |
| join_date | +-----------------+
| hash |
| reset |
+---------------+


Question would have records:


question
1 | "gender" | "Are you male or female?" | false
2 | "hobby" | "What do you like to do?" | false
3 | "age" | "How old are you?" | false

Then answers for user 1:


answer
1 | 1 | "male"
1 | 3 | 20


Then to query them:


SELECT m.id AS memberid, m.user, q.name, a.answer
FROM member m
LEFT JOIN answer a ON m.id = a.memberid
INNER JOIN question q ON q.id = a.questionid


Question could also make use of more fields to indicate what they can be. If you were to say it has to be an option, then give it options to select from, you can use that to force things like gender into male/female only options. My structure also assumes that you can only have one answer per question per user.

As for addslashes, do not use them in conjunction with mysql_real_escape_string. You should be:
- checking for magic_quotes_gpc
- if enabled, execute stripslashes on input
- insert/update using mysql_real_escape_string, or using prepared statement binding in PDO/MySQLi

Magic_quotes_gpc are now gone, but I'd suggest that you keep checking until PHP is at least 6.5. I'd suggest to bind a prepared statement instead of using an escape as well.

tangoforce
10-12-2012, 04:57 PM
Ah ok so when looking at..

See Fous latest reply. He's given you a really excellent example there.

I'd recommend you create the 3 tables that Fou has given you and just have a play around with them and the SQL until you see whats going on :thumbsup:

Gotta hand it to Fou, far more patience than me.. I could never draw up ascii tables like that :o

Fou-Lu
10-12-2012, 06:09 PM
Hah thanks my space bar is getting quite the workout :)
I'm still going to have to rehit the books on the crowfoot notation though. I did two different ones up for the same table structure, and something still doesn't look right o.O. I think the 1...n multiplier should be on the answers table, not the joined ones.

tangoforce
10-12-2012, 06:29 PM
Hah thanks my space bar is getting quite the workout :)

Lol

Talking of which, am I the only one suffering the "my keboard keys get louder and clunkier with age" syndrome? :confused:

I buy a new keyboard and its lovely and quiet. Within a few months its as loud as the last one :rolleyes:

PS I'm sure there used to be [ot] tags didn't there?

LearningCoder
10-12-2012, 06:57 PM
I am going to create those tables now and play around a bit and see where I get to.

When asking the user for input, do I simply use a normal html form? If so, do I display the questions from the database within the <label> tag?

Regards,

LC.

Fou-Lu
10-12-2012, 07:48 PM
I am going to create those tables now and play around a bit and see where I get to.

When asking the user for input, do I simply use a normal html form? If so, do I display the questions from the database within the <label> tag?

Regards,

LC.

You can yeah. If you simply query for the questions, you can display them with the field properties in a loop:


while ($row = $qry->fetch())
{
printf('<label for="qst_%d">%s</label>', $row['id'], $row['name']);
printf('<input type="text" name="answer[%d]" id="qst_%d"/>', $row['id'], $row['id']);
}

That would create text fields for each of the questions, and throw them into an array for answer. That can be iterated and the key=>value pairs can be used for an insert. Question table can be modified for input type controls too, so you can specify that its a selection from a list and give it options. If you were to normalize that, it would take a couple more tables.

As for keyboard noise, yep it definitely happens. It is mechanical of course, so will degrade with usage. Too bad I refuse to spend money every few months for a new one.

LearningCoder
10-12-2012, 08:03 PM
Thank you for that. So, does I set the questionID field in answer to auto-increment?

Regards,

LC.

Fou-Lu
10-12-2012, 08:17 PM
Thank you for that. So, does I set the questionID field in answer to auto-increment?

Regards,

LC.

Nope. That's a flattening table, you can use surrogates for both member and question, but you cannot use surrogates on answer. This uses a composite key of (memberid, questionid). You'll notice in my example I made use of 2x questions for a single user (1,1 and 1,3), but that can also be answered by a different user (2, 1 and 2, 2) for example. So neither of these keys in answer can be surrogate, they must relate to an existing on member and question tables. If you use innodb you can specify a key constraint on each of those to the parent tables, and even add cascade deletes to them (if you delete a question or delete a member, there is really no reason to keep the answers for the deleted question or user).

LearningCoder
10-12-2012, 08:22 PM
What do you mean when you say surrogates?

You mean I can use the auto-increment for the member and question tables but not the answers because we are pulling in the information from other tables?

Regards,

LC.

Fou-Lu
10-12-2012, 08:33 PM
Surrogate key (http://en.wikipedia.org/wiki/Surrogate_key).
Summary: It's a key that has no relation to actual data, and therefore in a normalized database really is never required. Proper normalization would indicate a different property be used for primary key, for example an email address if it must be unique. Data records only make sense though if at least one item is unique within them.
Problem is that its nicer in a web environment in particular to see userid=1 than to see email=email@place. I've personally used UUID for awhile now as I don't care for surrogate keys.

LearningCoder
10-12-2012, 08:43 PM
I was just on that site but couldn't understand what it was telling me. Your example was a little easier to grasp but still not 100% sure...

So, with the question table, the field types are int, varchar, varchar and boolean?

Kind regards,

LC.

Fou-Lu
10-12-2012, 08:51 PM
Yep. If you drop the surrogate off of it, you could use the `name` as the primary key (I assume that you never need more than one specific question).

LearningCoder
10-12-2012, 08:59 PM
Thanks, ok I've nearly created all them tables now.

I will stick to your first example because it's hard enough atm trying to understand this...lol

So now I need to populate my questions table with some questions right?

Sorry to sound so vague but I just want to take it a step at a time..:)

Kind regards,

LC.

Fou-Lu
10-12-2012, 09:02 PM
Yep, populate it as you see fit for questions.

LearningCoder
10-12-2012, 09:07 PM
Should I set the required field to a varchar and insert false? Everytime I try creating a boolean field, it converts to tinyint with a value of 1. I understand they are used as 0 = false, 1 = true...

Thanks for all the help, I could never have done this on my own :)

Regards,

LC.

Fou-Lu
10-12-2012, 09:30 PM
That's fine, the tinyint represents the boolean. Just like C, mysql doesn't have an actual boolean datatype, but its smart enough to convert it into a single bit integer. You can still provide it with true and false, and it will imply the 0 and 1 for it.
This field is only useful in the PHP world as you cannot enforce it otherwise. Although actual required fields would make more sense to be embedded into a non-null table column, I've included it for completion. Perhaps in the future you want to make it so a birthdate is a requirement (perhaps you have started serving adult information or whatever reason), so you now specify it as required, but the original design didn't include a birthday as a field. Without modifying the structure, the required attribute would let you enforce this with the software as PHP can simply throw an error and say that it is a required field. That just requires a selection for all the required fields to verify it has been provided with all of them (after an insert for the answered ones, I'd suggest using a join to determine what wasn't filled in and is required).

LearningCoder
10-12-2012, 09:38 PM
My intentions was to make none of the fields requirements, but simply if the user chooses to fill in their profile, then great, if not that's fine also.

So right now, when it is converting the 'boolean' to tinyint and setting it to 1, it is setting it to 'true' essentially??

Sorry, it is setting the length/value to 1, do I need to set the default value using the default drop down box, selecting as-defined, and typing 0?

If so I will set them to 0.

Kind regards,

LC.

Fou-Lu
10-12-2012, 10:15 PM
Set them to 0. You can specify a default parameter on that field to set them to 0 so you don't need to provided during an insert if you want. PHP wise false = 0, and true = !false.
With a tinyint, that sets the length to 1, as in 1 byte. So you are valid with any number between -128 to 127 signed or up to 0 to 255 for unsigned. Newer versions of mysql (5.0.5+ for innodb) can also use bit(1) which is one bit and therefore really makes more sense than a tinyint. I haven't a clue why they didn't chain boolean to bit as of that point.

LearningCoder
10-12-2012, 10:49 PM
Ah thanks. I've created it now.

Is it possible to take out the description field because I really only want to display the name part, like:



User Profile....:

First Name: <input field>
Age: <input field>
Hobbies: <inpt field>


And then when people view another users profile, they see:



First Name: Value
Age: Value
Hobbies: Value


Kind regards,

LC.

Fou-Lu
10-12-2012, 10:53 PM
Ah thanks. I've created it now.

Is it possible to take out the description field because I really only want to display the name part, like:



User Profile....:

First Name: <input field>
Age: <input field>
Hobbies: <inpt field>


And then when people view another users profile, they see:



First Name: Value
Age: Value
Hobbies: Value


Kind regards,

LC.

Yep, description is only something I added so you could add something to it if you wanted, just like the required field. All question really needs is a unique identifier, so you can get away with just name in that table as the PK (which would then become nothing more than a lookup table).

LearningCoder
10-13-2012, 12:54 AM
What I wanted to do is for the Gender do what you said and use a radio button where they can select only one.

Could you explain how to do that again because I cannot understand what you said earlier, i've gone over it several times.

Kind regards,

LC.

Fou-Lu
10-13-2012, 07:26 PM
There are a few different approaches depending on exactly what you want to do. If you want to allow multiple answers for the same question, it will take at least one more table to do this. If you wanted to fully normalize, it would be a few more (to bind options to specific lookups). That may be a bit overboard.
I'll take the middle ground. Partially normalized in the sense that the db itself is normalized, but not enforced. This allows multiple options, but because of the lack of enforced normalization, it will create slightly more complicated resultsets which will require more program interaction.
I'll do a partial implementation here. I used the following structure (note I just hooked into an existing principal table, so you'll need to modify the datatype of the answer for memberid and the reference to suit your structure):


--
-- Table structure for table `answer`
--

CREATE TABLE IF NOT EXISTS `answer` (
`memberid` varchar(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`question` varchar(50) NOT NULL,
`answer` varchar(50) NOT NULL,
PRIMARY KEY (`memberid`,`question`,`answer`),
UNIQUE KEY `question` (`question`,`answer`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `answer`
--

INSERT INTO `answer` (`memberid`, `question`, `answer`) VALUES
('5139c72e-6ca5-11e1-aa35-6cf049eecd83', 'bio', 'I is me.'),
('5139c72e-6ca5-11e1-aa35-6cf049eecd83', 'favoritecolour', 'blue'),
('5139c72e-6ca5-11e1-aa35-6cf049eecd83', 'favoritecolour', 'red'),
('5139c72e-6ca5-11e1-aa35-6cf049eecd83', 'gender', 'male');

-- --------------------------------------------------------

--
-- Table structure for table `question`
--

CREATE TABLE IF NOT EXISTS `question` (
`question` varchar(50) NOT NULL,
`description` varchar(255) NOT NULL,
`type` enum('select','multiselect','text','textarea','radio','checkbox') NOT NULL,
`required` bit(1) NOT NULL,
PRIMARY KEY (`question`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `question`
--

INSERT INTO `question` (`question`, `description`, `type`, `required`) VALUES
('bio', 'Give a quick description of yourself', 'textarea', b'0'),
('favoritecolour', 'What are your favorite colour(s)?', 'checkbox', b'0'),
('gender', 'What is your gender?', 'radio', b'0');

-- --------------------------------------------------------

--
-- Table structure for table `questionoption`
--

CREATE TABLE IF NOT EXISTS `questionoption` (
`question` varchar(50) NOT NULL,
`option` varchar(50) NOT NULL,
PRIMARY KEY (`question`,`option`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `questionoption`
--

INSERT INTO `questionoption` (`question`, `option`) VALUES
('favoritecolour', 'blue'),
('favoritecolour', 'green'),
('favoritecolour', 'indigo'),
('favoritecolour', 'orange'),
('favoritecolour', 'red'),
('favoritecolour', 'violet'),
('favoritecolour', 'yellow'),
('gender', 'female'),
('gender', 'male');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `answer`
--
ALTER TABLE `answer`
ADD CONSTRAINT `answer_ibfk_2` FOREIGN KEY (`memberid`) REFERENCES `user_user` (`userid`),
ADD CONSTRAINT `answer_ibfk_3` FOREIGN KEY (`question`) REFERENCES `question` (`question`);

--
-- Constraints for table `questionoption`
--
ALTER TABLE `questionoption`
ADD CONSTRAINT `questionoption_ibfk_1` FOREIGN KEY (`question`) REFERENCES `question` (`question`);


And wrote some quick code with:


<?php

$sQry = 'SELECT a.answer, q.question, q.description, q.required, q.type, qo.option, p.name
FROM answer a
RIGHT JOIN question q on q.question = a.question
LEFT JOIN questionoption qo ON qo.question = q.question
LEFT JOIN core_principal p ON p.pid = a.memberid
WHERE a.memberid="5139c72e-6ca5-11e1-aa35-6cf049eecd83" OR a.memberid IS NULL';

// funcs
function buildFieldset($legend, $sWrap)
{
$s = '<fieldset>' . PHP_EOL;
$s .= sprintf('<legend>%s</legend>' . PHP_EOL, $legend);
$s .= $sWrap;
$s .= '</fieldset>' . PHP_EOL;

return $s;
}

function buildCheckboxRadioGroup($name, array $aData, $sType)
{
$s = '';
foreach ($aData['option'] AS $opt)
{
$id = sprintf('profile_%s_%s', $name, $opt);
$s .= sprintf('<label for="%s">%s</label>' . PHP_EOL, $id, ucwords($opt));
$s .= sprintf('<input type="%s" id="%s" name="%s" value="%s"%s/>' . PHP_EOL,
$sType, $id, $name, $opt,
in_array($opt, $aData['selected']) ? ' checked="checked"' : '');
}
return buildFieldset($aData['description'], $s);
}

function buildTextarea($name, array $aData)
{
$s = '';
$id = sprintf('profile_%s', $name);
$s .= sprintf('<textarea id="%s">%s</textarea>' . PHP_EOL, $id, implode($aData['selected']));

return buildFieldset($aData['description'], $s);
}


// end funcs

if ($qry = mysql_query($sQry))
{
$aRecords = array();
while ($row = mysql_fetch_assoc($qry))
{
if (!isset($aRecords[$row['question']]))
{
$aRecords[$row['question']] = array(
'description' => $row['description'],
'required' => $row['required'],
'type' => $row['type'],
'option' => array(),
'selected' => array(),
);
}
if (!in_array($row['option'], $aRecords[$row['question']]['option']))
{
$aRecords[$row['question']]['option'][] = $row['option'];
}
if (!in_array($row['answer'], $aRecords[$row['question']]['selected']))
{
$aRecords[$row['question']]['selected'][] = $row['answer'];
}
}


foreach ($aRecords AS $name => $rec)
{
switch ($rec['type'])
{
case 'radio':
print buildCheckboxRadioGroup($name, $rec, 'radio');
break;
case 'checkbox':
print buildCheckboxRadioGroup($name, $rec, 'checkbox');
break;
case 'textarea':
print buildTextarea($name, $rec);
break;
}
}
}
else
{
print 'An error occurred with querying: ' . mysql_error();
}


Which for my selected userid hardcoded into the query gave me:


<fieldset>
<legend>Give a quick description of yourself</legend>
<textarea id="profile_bio">I is me.</textarea>
</fieldset>
<fieldset>
<legend>What are your favorite colour(s)?</legend>
<label for="profile_favoritecolour_blue">Blue</label>
<input type="checkbox" id="profile_favoritecolour_blue" name="favoritecolour" value="blue" checked="checked"/>
<label for="profile_favoritecolour_green">Green</label>
<input type="checkbox" id="profile_favoritecolour_green" name="favoritecolour" value="green"/>
<label for="profile_favoritecolour_indigo">Indigo</label>
<input type="checkbox" id="profile_favoritecolour_indigo" name="favoritecolour" value="indigo"/>
<label for="profile_favoritecolour_orange">Orange</label>
<input type="checkbox" id="profile_favoritecolour_orange" name="favoritecolour" value="orange"/>
<label for="profile_favoritecolour_red">Red</label>
<input type="checkbox" id="profile_favoritecolour_red" name="favoritecolour" value="red" checked="checked"/>
<label for="profile_favoritecolour_violet">Violet</label>
<input type="checkbox" id="profile_favoritecolour_violet" name="favoritecolour" value="violet"/>
<label for="profile_favoritecolour_yellow">Yellow</label>
<input type="checkbox" id="profile_favoritecolour_yellow" name="favoritecolour" value="yellow"/>
</fieldset>
<fieldset>
<legend>What is your gender?</legend>
<label for="profile_gender_female">Female</label>
<input type="radio" id="profile_gender_female" name="gender" value="female"/>
<label for="profile_gender_male">Male</label>
<input type="radio" id="profile_gender_male" name="gender" value="male" checked="checked"/>
</fieldset>



You'd need to write the handling functions for the remaining enum types.

LearningCoder
10-25-2012, 09:28 PM
That's probably the most complicated PHP I've seen. I just re-read the thread.

I've created tables members, questions and answers.

I ran a simple select query on the questions table and tried returning some <label>'s with the question inside it, as you showed me before on page 2 I think it is.

When I run this code:


<?php

$con = new mysqli("localhost","root","","demo_central");

$stmt = $con->prepare("SELECT * FROM questions");
$stmt->bind_result($id, $name);

$stmt->execute();

$stmt->store_result();

while ($row = $stmt->fetch())
{
printf('<label for="qst_%d">%s</label>', $row['id'], $row['name']);
printf('<input type="text" name="answer[%d]" id="qst_%d"/>', $row['id'], $row['id']);
}
?>


It returns only the <input>'s but no text or no label.

My table is structured as questions->id(int), name(varchar).

What am I doing wrong?

Kind regards,

LC.

Fou-Lu
10-25-2012, 10:33 PM
$stmt->fetch won't return a result. You have bound to $id and $name.


while ($stmt->fetch())
{
printf('id: %s, name: %s' . PHP_EOL, $id, $name);
}

LearningCoder
10-25-2012, 11:36 PM
I've officially given up. Well out of my depth here. I just cannot figure out how to do this dynamically and I'm going to need to do it like that to be able to get that site working how I want.

Thanks for your ideas and help but I just can't do it.

Kind regards,

LC.

LearningCoder
10-26-2012, 01:37 AM
Well, I couldn't leave it alone, it was pecking my head. So, I carried on and this is what I have. I am wondering if there is a way to fill the input fields with any data which might exist for their profiles already.



<?php
session_start();

function build_form($labels){
$c = 1;
$form = "<form id='profile' name='profile' method='post' action='membersarea.php'>";
$form .= "<fieldset><legend>Edit Your Profile</legend>";
foreach ($labels as $l){
$form .= "<p><label for='qst_{$c}'>".$l."</label><input type='text' name='qst_{$c}' id='qst_{$c}' size='32' maxlength='40' /></p>";
$c++;
}
$form .= "<p><input type='submit' name='submit' value='Update Profile' /></p>";
$form .= "</fieldset></form>";
return $form;
}


$mode = (isset($_REQUEST['content'])) ? mysql_real_escape_string($_REQUEST['content']) : "";

switch ($mode) {
case 'edit':
$questions = include("profile_query_include.php");
$form = build_form($questions);
$output = $form;
break;

case 'process_edit':


break;

case 'view':
$output = file_get_contents("view_profile.htm");
break;

case 'uploads': $output = file_get_contents("user_uploads.htm");

break;

case 'new': $output = file_get_contents("new_upload.htm");

break;

default: $output = file_get_contents("default_template.htm");
}

$page = $_SERVER['REQUEST_URI'];
$name = ucwords(str_replace(array(".php","_"),array(""," "),substr($page,strrpos($page, "/", -1)+1)));
$lower = strtolower($name);

if(!isset($_SESSION['username'])){
header("Location: index.php");
exit(0);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo-Central <?php print $name; ?> Page</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<script type="text/javascript" src="javascripts/advert.js"></script>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<link rel="stylesheet" type="text/css" href="css/fontface.css" />
<link rel="stylesheet" type="text/css" href="css/menu.css" />
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
</head>
<body onload="window_onload()">

<?php require("header_include.php"); ?>

<div id="content">
<p id="welcome_member">Welcome,
<span id="member"><?php echo $_SESSION['username'];?></span>
<span id="logout"><a href="logout.php">Logout</a></span>
</p>
<hr id="welcome_hr" noshade="noshade" />

<div id="profile_div">
<a href="membersarea.php?content=edit">
<img src="images/outline.png" alt="Profile" name="Profile" id="profile_pic" border="0" />
</a>
</div>

<div id="memberInfoDiv">
<div id="date_div"></div>

<a href="membersarea.php?content=view">View your profile.</a>
<a href="uploads">View your uploaded files.</a>
<a href="new">Upload a new file.</a>

</div>

<?php print($output);?>

</div>

<?php require("footer_include.php"); ?>

</body>
</html>


I can't figure out your query Fou, would you be able to split those up into separate ones, just for me to get my head around it?

Kind regards,

Lc.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum