Loading...


bookmark - How To Create A "user Profile" Page. No design (easy to add later if you want).

How To Create A "user Profile" Page. - No design (easy to add later if you want).

 
 Discussion by Feelay with 37 Replies.
 Last Update: May 19, 2012, 1:49 pm ( View Rated (10) ) (View Latest)
Page 1 of 2 pages.
bookmark - How To Create A "user Profile" Page. No design (easy to add later if you want).  
Quickly Post to How To Create A "user Profile" Page. No design (easy to add later if you want). w/o signup Share Info about How To Create A "user Profile" Page. No design (easy to add later if you want). using Facebook, Twitter etc. email your friend about How To Create A "user Profile" Page. No design (easy to add later if you want). Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print


Hi!

It was a long time ago I created a tutorial, so I've decided to create a new one :(

This time, I am going to teach you, how to create a "user profile page".
Lets say I am logged in on my account, and want to view someone else account information (in this case, only his username, but you can add more things
later).
Then I'll press on a link, that will take me to his user profile.
But before you can do that, you will have to create a register script, and a login script.

If you don't know how to create any of those, you can find tutorials here:
Login-Scipt Tutorial
Register-Script Tutorial

You will be using the same database, as the earlier tutorials.

Before I start, I just want to say that I would never have learned this, without some guys here on Astahost. So don't give me all the credits.
I think that vujsa, mastercomputers, Mordent and ethergeek, deserve some credits too. Because they teached me some of these things, that I am going to teach
you.




Lets start with the "Member List". To be able to see all the members that's registered on the page, with a link to their profile, we need a member list page.
Lets start with the code.


Members.php

CODE

<?php
session_start();
require 'database.php';
$nuser=$_SESSION['user'];
$auser=$_SESSION['admin'];

if($nuser){
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
}
if(isset($userfinal)){
$Members = mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error());
$numRowsMembers = mysql_num_rows($Members);
?>

<table border="0">

<?php
for($count = 1; $count <= $numRowsMembers; $count++)
{
$name = mysql_fetch_array($Members);
?>

<tr>
<?php
echo '<td><a href="member_profile.php?username=' . $name['user'] . '">' . $name['user'] . '</a></td>';
?>
</tr>

<?php
}
?>
</table>



So.. This is the Member List. I called it "members.php".
I think you want to know what it does, or?

The first thing we do, after the PHP tag, is starting a session. Not so hard..
Then we require the database file (I'll add it in the end of this tutorial).
Then, I create two variables.
The "$nuser" is for the "non-admin" user (normal user).
The "$auser" is for the "Admin" user.
After that I've created theese two variables, I check if the user is an Admin, or a Normal user, and insert the $nuser and $auser variable in the $userfinal

variable. now it is easy to check if the user is logged in. Instead of first checking if a Normal user is logged in, and then check if an admin is logged, I

check if both is logged in, much faster. (hard to explain :P but this way is much easier).
Now this explanation was for the "if(isset($userfinal)){" part.
After that, I create two new variables again.
The first one will get all the "Normal users" from the database.
The other one will retrieve the number of rows from the first query.

Then I create an Invisible Table, so that the names looks good, and so that the table don't screw up the design (if you use one.)
But OFC, if you want to make the table visible, you can change the "border" to a number larger than 0.

Now after that, we create a for-loop, to show all the names on the screen (the member list), and all the names, will have a link to their profile.




easy, wasn't it? If there is something you didn't understand, you are free to contact me and ask.
Now lets begin with the "member_profile" page.





member_profile.php


CODE

<?php
session_start();
require 'database.php';
$nuser=$_SESSION['user'];
$auser=$_SESSION['admin'];

if($nuser){
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
}
if(isset($userfinal)){

$username = $_GET['username'];
$user = mysql_query("SELECT * FROM user WHERE username = '$username'");
$user=mysql_fetch_assoc($user);
if($user['level'] > 1){
die("You cant view an Admins profile!");
}

echo "<h1>User Info</h1>";

echo "<b>Username:".$user['username']."<br>";

echo "<br>";
echo '<form name="backlistfrm" method="post" action="members.php">';
echo '<input type="submit" value="Back to The List">';
echo '</form>';
echo "<br>";

?>


Here we start like we did in the first page.
After the php tag, We start a session, and require the database file.
then we create two variables ($auser = admin and $nuser= normal user).
Then we create the $userfinal variable, to check if the user is logged in later in the script.
Then we create some variables.


CODE

$username = $_GET['username'];
This is the variable for the name that we pressed on in the member list page.

CODE

$user = mysql_query("SELECT * FROM user WHERE username = '$username'");
This variable will select all the info about that person.

CODE

$user=mysql_fetch_assoc($user);
This will make us able to select something specific about that person when we are writing the code.

Now we check if the user that we selected is a normal user, or an admin. If the user is an admin, an error will occur that the user can't view the admins

profile. If you want you can remove this part:



CODE

if($user['level'] > 1){
die("You cant view an Admins profile!");
}


This will make the users able to view an admins profile.

Then the info about the user will be shown.
In this case, I've only added the username of the user ->

CODE

echo "<b>Username:".$user['username']."<br>";


But OFC, you can add more. Just change the user inside the ['...'] to something else from the database table, that you want to show.

(lets say you want to show the users Admin level instead of his username, then you can change the $user['username'] to $user['level'].)

The last thing I do in this script, is adding a button that will take the user back the the member_list.




And here is the database.php file:

CODE

<?
$con = mysql_connect('localhost','mysql_username','mysql_password');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('databasename');
?>


the first thing we do here, is:
Open a connection to the mysql server.
If the connection failed, the code will write an error
then, we select the database we want to use.



If you find anything spelled wrong, or any code that I wrote, that is wrong, or if you find something that is not working as it should, paste the wrong

word(s) or the wrong code(s) or the error(s), and I'll fix them.

Regards //Feelay




You are not allowed to copy anything from this tutorial, and paste it outside of this topic, without my permission.
But you are allowed to copy/paste parts of it, inside this topic.

   Sun May 25, 2008    Reply         

Hello!
Thank you for the tutorials that you have made. It has helped me a lot with my website.
Just one question about this one; I only get "Parse error: syntax error, unexpected $end" in the members profile. It says line 35.
Do you think you could help me out ;)? Would be really nice.

+
Theres no such table as user.characters in your login/registration script either. Whats supposed to be in that one?
Thanks








   Sat Sep 13, 2008    Reply         

QUOTE (lysvir)

Hello!
Thank you for the tutorials that you have made. It has helped me a lot with my website.
Just one question about this one; I only get "Parse error: syntax error, unexpected $end" in the members profile. It says line 35.
Do you think you could help me out ;)? Would be really nice.
Link: view Post: 128256


add this, before the "?>".

CODE

} else {
echo "You are not logged in. Please log in to continue";
}


QUOTE (lysvir)

+
Theres no such table as user.characters in your login/registration script either. Whats supposed to be in that one?
Thanks
Link: view Post: 128256


I think I was using a different database when I created that tutorial.
just change the "user" to the column in your database that takes care of all usernames.
and change characters, to the name of the table you are using to store all the data.


Good luck with you site, and thanks for the comments ;)

   Mon Sep 15, 2008    Reply         


Now this is my member_profile.php page. Is there something wrong with it as it wont show the username ?
The session name is username and the db file is db.php.

CODE

<?php
session_start();
require 'db.php';
$nuser=$_SESSION['username'];
$auser=$_SESSION['admin'];

if($nuser){
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
}
if(isset($userfinal)){

$username = $_GET['username'];
$user = mysql_query("SELECT * FROM user WHERE username = '$username'");
$user=mysql_fetch_assoc($user);
if($user['level'] > 1){
die("You cant view an Admins profile!");
}

echo "<h1>User Info</h1>";

echo "<b>Username:".$user['username']."<br>";

echo "<br>";
echo '<form name="backlistfrm" method="post" action="members.php">';
echo '<input type="submit" value="Back to The List">';
echo '</form>';
echo "<br>";

} else {
echo "You are not logged in. Please log in to continue";
}

?>

   Mon Sep 15, 2008    Reply         

try to echo the $user = mysql_query("SELECT * FROM user WHERE username = '$username'");

add echo $user; under it.. like this.

CODE

$user = mysql_query("SELECT * FROM user WHERE username = '$username'");
echo $user;


then write the output of the echo, here.

   Tue Sep 16, 2008    Reply         

Thanks! Now everything works perfect.
Can I just ask one more question?
Is it hard to make a script within this one, that let's the users upload a profile picture to the database?
I'm currently running everything on localhost with a phpmyadmin system.
I'm thinking something like a profile page that will show:

CODE

[PROFILE PICTURE]
- [PROFILE NAME]


That this will be shown to the user visiting the profile?
localhost/member_profile.php?username=Test
This will then show the username: TEST and the profile picture that TEST has uploaded.

Is this hard to make?

   Wed Sep 17, 2008    Reply         


hmm.. I've never really studdied file upload. But it shoudln't be hard to make. You just have to know how to do it. I havn't studdied these things, and therefor, I'm afraid I can't help you =/
sorry. But I am sure that someone else here can.

EDIT: Try searching for UPLOAD PICTURES TO A MySQL DATABASE on Google ;) you should find lots of things.

Here is a good Link =)
Inserting pictures to a mysql database


Wishes //Feelay

   Wed Sep 17, 2008    Reply         

Thanks for the fast reply, Feelay!
I will check it out ^^,

   Wed Sep 17, 2008    Reply         

QUOTE (Feelay)

hmm.. I've never really studdied file upload. But it shoudln't be hard to make. You just have to know how to do it. I havn't studdied these things, and therefor, I'm afraid I can't help you =/
sorry. But I am sure that someone else here can.

EDIT: Try searching for UPLOAD PICTURES TO A MySQL DATABASE on Google ;) you should find lots of things.

Here is a good Link =)
Inserting pictures to a mysql database
Wishes //Feelay
Link: view Post: 128356



Just wondering with legal stuff and all, if any of us used this code on a commerical site would we get sued? or are we freely able to use it?

   Thu Sep 18, 2008    Reply         

Hi again Feelay.
I'm working on a website that should contain text like this when logged in:
Welcome [username].
But my problem is, how can I make the user see their own profile page just by clicking their username here?
I tried this solution (which didn't work):

at the start:

CODE

<?php
session_start();
require_once 'db.php';
if (isset($_SESSION['username'])){
$user = $_SESSION['username'];
?>


Where I wanted the "Welcome [username]" without the "welcome" part:

CODE

<h4>Logged in</h4>
<fieldset>
<a href = "<?php echo "member_profile.php?username=$user"; ?>"><?php echo $user; ?></a>
<a href="logout.php">Log out</a>
</fieldset>


Do you know any working solution for my problem ;)?
Thanks.

   Thu Sep 18, 2008    Reply         

QUOTE (bricktop11)

Just wondering with legal stuff and all, if any of us used this code on a commerical site would we get sued? or are we freely able to use it?
Link: view Post: 128389


The code is mine. I got some help from people here on astahost, with some functions. But the whole script is made by me. You are allowed to use it. This is just a beginner script :P So it doesn't really matter :P

QUOTE (lysvir)

Hi again Feelay.
I'm working on a website that should contain text like this when logged in:
Welcome [username].
But my problem is, how can I make the user see their own profile page just by clicking their username here?
I tried this solution (which didn't work):

at the start:

CODE

<?php
session_start();
require_once 'db.php';
if (isset($_SESSION['username'])){
$user = $_SESSION['username'];
?>


Where I wanted the "Welcome [username]" without the "welcome" part:

CODE

<h4>Logged in</h4>
<fieldset>
<a href = "<?php echo "member_profile.php?username=$user"; ?>"><?php echo $user; ?></a>
<a href="logout.php">Log out</a>
</fieldset>


Do you know any working solution for my problem ;)?
Thanks.
Link: view Post: 128391


hmm.. I don't understand =/

If you mean what you think you mean, try:

A simple if statement should be able to do it.
If the session user is set, show the welcome, else, show just the name of the user.


If that is not what you mean, please reask the question, but try to explain more ;)

Wishes //Feelay

   Fri Sep 19, 2008    Reply         

I managed to figure it out by my self ^^,!
This is the code to the profile page:

CODE

<?php echo '<td><a href="member_profile.php?username=' . $_SESSION['username'] . '"> Your ingame stats/profile</td>'; ?>

   Fri Sep 19, 2008    Reply         

thank you so much ... that was a big help...

   Sun Sep 21, 2008    Reply         

Feelay, this script is great. I'm integrating it into a login/registration script I already have in place and I'm not sure if I'm doing something wrong. The members.php page gives me this error.
Parse error: parse error, unexpected $ in ..../members.php on line 34 (which is the end of the script and there is only a </table> tag, but no $ or other php info.

My table and fields are slightly different, but I haven't changed anything else. Any thoughts?

CODE

<?php
session_start();
require 'include/database.php';
$nuser=$_SESSION['user'];
$auser=$_SESSION['admin'];

if($nuser){
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
}
if(isset($userfinal)){
$Members = mysql_query("SELECT username FROM users WHERE userlevel ='1' ORDER BY exp DESC") or die(mysql_error());
$numRowsMembers = mysql_num_rows($Members);
?>
<table border="0">
<?php
for($count = 1; $count <= $numRowsMembers; $count++)
{
$name = mysql_fetch_array($Members);
?>
<tr>
<?php
echo '<td><a href="member_profile.php?username=' . $name['user'] . '">' . $name['user'] . '</a></td>';
?>
</tr>
<?php
}
?>
</table>

   Sun Sep 28, 2008    Reply         

QUOTE (sozo33)

Feelay, this script is great. I'm integrating it into a login/registration script I already have in place and I'm not sure if I'm doing something wrong. The members.php page gives me this error.
Parse error: parse error, unexpected $ in ..../members.php on line 34 (which is the end of the script and there is only a </table> tag, but no $ or other php info.

My table and fields are slightly different, but I haven't changed anything else. Any thoughts?

CODE

<?php
session_start();
require 'include/database.php';
$nuser=$_SESSION['user'];
$auser=$_SESSION['admin'];

if($nuser){
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
}
if(isset($userfinal)){
$Members = mysql_query("SELECT username FROM users WHERE userlevel ='1' ORDER BY exp DESC") or die(mysql_error());
$numRowsMembers = mysql_num_rows($Members);
?>
<table border="0">
<?php
for($count = 1; $count <= $numRowsMembers; $count++)
{
$name = mysql_fetch_array($Members);
?>
<tr>
<?php
echo '<td><a href="member_profile.php?username=' . $name['user'] . '">' . $name['user'] . '</a></td>';
?>
</tr>
<?php
}
?>
</table>

Link: view Post: 128691

****UPDATED****
Okay, I realized that the bracket at if(isset($userfinal)){ has two closed brackets in the above code. Being a newbie, I'm not sure where to open another one, or eliminate one of the closed brackets so that they all cancel out. Maybe this will help anyone who looks at this. Thanks in advance!

   Sun Sep 28, 2008    Reply         

I changed this:


$Members = mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error());


  to this


$Members = mysql_query("SELECT user FROM user WHERE level ='1' ORDER BY exp DESC") or die(mysql_error());

in member.Php,  than I got this error? "Unknown column 'user' in 'field list'"How do I fix this?


I think I was using a different database when I created that tutorial.Just change the "user" to the column in your database that takes care of all usernames.And change characters, to the name of the table you are using to store all the data.
? whot do you mean :P eeeh

-reply by UtubeKeywords: create php profile

   Thu Feb 12, 2009    Reply         

cool thanks

   Fri Apr 10, 2009    Reply         

i saw a tutorial just like this one on trap17 its quite old.i found it out when i was searching for a free login and registration script.Will have to find it out. :o

   Fri Apr 10, 2009    Reply         

A step by step tutorial how to create a signin, signup and profile using phpHow To Create A "user Profile" Page.

 I know I am asking too much This "a stet by step tutorials on how to create a sign in page, sign up page or register script and a user profile page". Just like what Freelay posted here. The problem is I'm not a webmaster or a compter expert but I believe that if somebody will make a step by step tuturials I could learn as what I am always doing now. Just for example if somebody will say: First to do is "create a table, then go here and go there, click here and click there, eccc, second create a bla bla bla...And so on...So doing like this I think many peole will be happy like me.

Like me I want this in my website but I don't know how to do it:

that can [font=" -webkit-monospace; font-size: 13px; white-space: pre-wrap"]provides the following facilities:[/font]

* Authentication* Signup page* Account confirmation* Login / logout / log as someone else* Edit account* I have lost my login!* I have lost my password!* Delete account
 *A profile page which users can edit their account if they want
This is I want to create and put it in my website. I thinking to make a website where anyone can sign up and make their own account and have a website like mine. A website with multiple Users.
Can anybody help me about this or suggest me some tutorials site?
I really need your help guys, Thank you in advance.

-reply by socrates

   Mon Jul 6, 2009    Reply         

i need a way i can add seperate profiles to each user. Can anyone help?!How To Create A "user Profile" Page.

I'm looking for a system where u log in and I takes u to your profile page in which u can edit.

Ive already got the log in/register stuff sorted but I need profile pages. A bit like myspace of facebook.

If any one knows of anyway to do this please say so or give me a link. Thank you 

-reply by flagman186

   Sun Jul 26, 2009    Reply         

good tutorials freelay
keep on with such tutorials
as you spread your knowledge

   Sat Oct 17, 2009    Reply         

Now, I got another good site. :D

   Mon Nov 2, 2009    Reply         

Nice tutorials freelay. Didn't knew they were here in astahost. I think i need to look for threads by searching now. Thanks for thread-bump hannah.

   Tue Nov 3, 2009    Reply         

Web Design CSSHow To Create A "user Profile" Page.

I am in a software program design class at Springfield Clark CTC in Ohio and am currently learning about css. I know how to link all thepages together, change padding, bordercolor and width and alot of other things but would this code be set up in a css stylesheet, embedded? How should I put the code in.

[img]/txtmngr/images/smileys/smiley13.Gif[/img]

-reply by Nicole Stephson

 

   Wed Dec 2, 2009    Reply         

FTP servers, php filesHow To Create A "user Profile" Page.

I am creating a website with a friend and have currently downloaded a FTP thing for firefox. To create this to be used on my website how would I set it up?

I am wanting to do profiles for my website antisocialonline.Webs.Com and need to use the codes. When creating these in note pad or another source should I use the file extension .Php or something else?

[img]/txtmngr/images/smileys/smiley11.Gif[/img]

 

-reply by Nicole

 

   Wed Jan 13, 2010    Reply         

header error - regcheckHow To Create A "user Profile" Page.

hello I'm building to login, reg and member profile parts and I am having an issue with regcheck.Php.

 

You Are Registered And Can Now LoginWarning: Cannot modify header information - headers already sent by (output started at/Applications/XAMPP/xamppfiles/htdocs/gigbasket/regcheck.Php:44) in /Applications/XAMPP/xamppfiles/htdocs/gigbasket/regcheck.Php on line 47

 

 I have try a fresh install of xampp   and tried changing the header to direct to other files but I still get the same???

 please help

thanks

rick

 

   Thu Feb 11, 2010    Reply         

I'm trying this on my new website. For some reason if I go to the Members page it says "Table 'databaseName.charecters' doesn't exist". How can I fix it?

   Wed Feb 24, 2010    Reply         

QUOTE (HannahI)

I'm trying this on my new website. For some reason if I go to the Members page it says "Table 'databaseName.charecters' doesn't exist". How can I fix it?
Link: view Post: 145221

And does this table exist?

   Wed Feb 24, 2010    Reply         

I'm not sure. It doen't say anything like that in the script, does it?

   Wed Feb 24, 2010    Reply         

QUOTE (HannahI)

I'm not sure. It doen't say anything like that in the script, does it?
Link: view Post: 145224

"databaseName.charecters" Such a name is necessarily coming from somewhere ! Have a look inside your files, you will necessarily find it.

   Wed Feb 24, 2010    Reply         

Quickly Post to How To Create A "user Profile" Page. No design (easy to add later if you want). w/o signup Share Info about How To Create A "user Profile" Page. No design (easy to add later if you want). using Facebook, Twitter etc. email your friend about How To Create A "user Profile" Page. No design (easy to add later if you want). Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print


Similar Topics:

Creating New Process Under Alternat...

I am having quite the time spawning a process under a different user context. My preferred method involves using the Windows API functions LogonUser() and CreateProcessAsUser() but I have not figured out a way to overcome several error messages. I also have the particular problem of running my pro ...more

   10-Jul-2006    Reply         

Can 39 t Load The User Profile In ...

A client of mine have a notebook running Windows Vista Premium edition configured with five different users accounts, where only one of these accounts is able to log on to the system and starts it's session correctly. The other four accounts can't be able to do this, and instead ...more

   22-Dec-2008    Reply         

Help Regarding Creating User Profil...

Hello guys i want to create a user profile for the user that appears similar to the user profile of this site.With which tools i can design that and what are the technologies that are necessary to create this sort of user profiles and which is the best tool & technology to create them ...more

   09-Feb-2009    Reply         

Calendar And The Date () Function Making Math Simple With Modular Arithmetic   Calendar And The Date () Function Making Math Simple With Modular Arithmetic (0) (3) How To Find And Test Imagemagick Using Php   How To Find And Test Imagemagick Using Php