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
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'];
?>

Link to comment
Share on other sites

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'];
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.