PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Well I want to add some of my own PHP profile pages. I started learning PHP less then a week ago so I know some basics but i'm not that good. I don't really want free scripts from anyone. But i'd like to know what pages I need to create, what PHP codes i'll need to use and look up and how hard it'll be to create.
Can you be a little more specific? What do you mean "profile pages"? You mean like you want to make a social networking website, or you just want a personal web page?
Well, you would want a registration page where they enter the information. Another page that displays their profile based on their name or id. Then you would need to setup a MySQL database & table to store all the data. You might also want to have a login system. It shouldn't be too hard.
You would just need to create one table to store all the user data. Then you generate the pages based on that data. You generate the links to the profiles based on the usernames like:
profile.php?user=CoolDude101
So you just loop through the rows in the database generating links using the user's username. Then on the profile page you select the row with the username, then use that data to generate a page.
Cirdan wrote:You would just need to create one table to store all the user data. Then you generate the pages based on that data. You generate the links to the profiles based on the usernames like:
profile.php?user=CoolDude101
So you just loop through the rows in the database generating links using the user's username. Then on the profile page you select the row with the username, then use that data to generate a page.
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="Persons"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
<?php
$host="localhost"; // Host name
$username=NULL; // Mysql username
$password=NULL; // Mysql password
$db_name=NULL; // Database name
$tbl_name="Persons"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Profile</title>
</head>
<body>
<?php
include ('database.php');
$result = mysql_query("SELECT * FROM `Persons`;") or die(mysql_error());
// before you echo result you also need to evaluate result that comes from call to mysql_query()
// read more at: http://lt.php.net/mysql_fetch_row
// echo $result;
?>
</body>
</html>