Jump to content
xisto Community

Creating Profiles In Php/mysql ?

Recommended Posts

i've started to learn php..im familiar to basics of php and mysql now.Now for example i want that some user can register to my website , and after that he can Login and log out , and he can see his profile.is there any tutorial about this ? or any helping url .. or any helping answer please :)

Share this post

Link to post
Share on other sites

hey check out http://www.phpfreaks.com/ there is a tutorial on user/membership on there. As for users + profiles, you could add a table to your database called UserProfs or something else with these columns.


Email Address,

Real Name

and more then just create a php file like this:

<?phpif (isset($user)) {$db_server = "localhost";$db_database = "members";$db_user = "user";$db_pass = "pass";mysql_connect($db_server, $db_user, $db_pass) or die("Could not connect to database server.");mysql_select_db($db_database) or die("Could not select database.");$query = "SELECT * FROM $db_database WHERE username=$user";$results = mysql_query($query);$num = mysql_numrows($results);if ($num > 0) {$email = mysql_result($results, 0, "Email Address");$realname = mysql_result($results, 0, "Real Name");print "<b>Username:</b> $user<br>";print "<b>Email:</b> $email<br>";print "<b>Real Name:</b> $realname<br>";$a++;}}?>

just learn php/mysql there are plenty of tutorials out there and its not that hard to do, here is a good tutorial that helped me: http://www.freewebmasterhelp.com/tutorials/phpmysql

Share this post

Link to post
Share on other sites

I'm going to go ahead and jump in here, its quite easy actually.
As long as you understand how to use $_SESSION,$_GET,$_POST,$_REQUEST(optional, not necessary)
but for profiles, concentrate on $_GET. Jmb was partially correct, but instead of doing that, why not just directly take the details from the user database rather than creating one more with duplicate fields and values?

Follow this,itssame :

For example, your database has a table called 'users' and its fields are username,rank,email.

Code :

<?php//call in your connection filerequire('connection2.php'); //Select from the database, the row which has the username of $_GET[profile] as give in the url. Example : url.com?a=account&s=session&profile=Test$query=mysql_query("SELECT * FROM users WHERE username='$_GET[profile]'");//Check the number of rows that are there in the database with the username of $_GET[profile], in this case Test is the account.$count_rows=mysql_num_rows($query);if ($count_rows >= 1) {$r=mysql_fetch_array($query);//above, we set $r to all the fields main display variable .echo "Username  : $r[username] \n";echo "Email : $r[email] \n";echo "Rank : $r[rank] \n";}else {echo "No records of user.";}mysql_close(connection_variable);?>

Thats the most basic script. You can modify it to your needs.
Edited by ewcreators (see edit history)

Share this post

Link to post
Share on other sites

I set in a reminder that if you plan to use a user registration script tutorial, that you also find security tutorials as well because I only can imagine how quickly someone could get into your hosting account and then do their damage. Of course if your trying to learn php then it is well worth the effort to get a understanding of how it works, but if you going to use them you want to look for software that has some sort of registration script already set up with it that comes with some sort of security.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.