Jump to content

dynamically create user pages


hitokirikensan

Recommended Posts

Hi, i coded a very simple forum "website" with registration, login, and a place where everyone posts comments.  I wanted to make some sort of profile page for each user so they would each have their own URL too (e.i. test/barney or test/simpsons).  each of these pages would have different content, depending on what barney or simpsons puts on that page.

 

i've been looking everywhere trying to find documentation but i don't think i know how to search it correctly. I checked a lot of mod_rewrite documentation but i don't understand if i'm suppose to call a php function to create a profile page or something.

 

Any guidance would be greatly appreciated

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/
Share on other sites

Just a rough idea...

<?PHP
session_start();
/* determine what user is here */
$user_id = $_SESSION['user_id'];
/* connect to database */
include('db.php');
/* create a query */
$query = "SELECT * FROM user_data_table_name WHERE id = '$user_id'";
/* execute the query */
$result = mysql_query($query);
/* put the data into an array */
$row = mysql_fetch_array($result);
/* display the data for the particular user */
echo $row['name'] . "<br/>";
echo $row['dob'];
?>

ok more rough code...

 

a portion of the form which visitor/user can select who they want to see (you could populate this using php, mysql and a loop)

 

<select name="what_user_id">
<option value="1">Jack Nicholson</option>
<option value="3">Santa Claus</option>
<option value="27">Batman</option>
<option value="77">The Joker</option>
</select>

now the info display page

<?PHP
session_start();
/* determine what user is here */
$user_id = $_POST['what_user_id'];
/* connect to database */
include('db.php');
/* create a query */
$query = "SELECT * FROM user_data_table_name WHERE id = '$user_id'";
/* execute the query */
$result = mysql_query($query);
/* put the data into an array */
$row = mysql_fetch_array($result);
/* display the data for the particular user */
echo $row['name'] . "<br/>";
echo $row['dob'];
?>

I needed to create dynamic hyperlinks with

<?php
				$value=mysql_query("SELECT screenname FROM users");
				while($list=mysql_fetch_assoc($value))
				{
					$owner=$list[screenname];
					echo "<a href='/php/profile.php?action=makepage&owner=$owner'>$owner<br></a>";

				}
				?>

Then i created a profile.php with function makepage() and got the value from the URL

function makepage()
{
$owner=$_GET['owner'];
include '../pp.html';
}

this way, the owner of the page is known (reflected in the URL) and i just created a basic profile page

<body>
This is <?php if($_SESSION[screenname]=owner){echo "your";} else{echo $owner;} ?> page

</body>

 

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.