hitokirikensan Posted January 24, 2011 Share Posted January 24, 2011 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 More sharing options...
litebearer Posted January 24, 2011 Share Posted January 24, 2011 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 https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164391 Share on other sites More sharing options...
hitokirikensan Posted January 24, 2011 Author Share Posted January 24, 2011 But with that code, i won't be able to view other member's profile pages. So if i'm jack_nicholas, i won't be able to see santa_claus's profile page Link to comment https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164396 Share on other sites More sharing options...
litebearer Posted January 24, 2011 Share Posted January 24, 2011 do you want jack to see santa's info and vice versa? Link to comment https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164399 Share on other sites More sharing options...
hitokirikensan Posted January 24, 2011 Author Share Posted January 24, 2011 yes, every user should have their own profile page that other's can view Link to comment https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164401 Share on other sites More sharing options...
litebearer Posted January 24, 2011 Share Posted January 24, 2011 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 https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164405 Share on other sites More sharing options...
hitokirikensan Posted January 24, 2011 Author Share Posted January 24, 2011 if i have a profilepage.html which the php includes, how would i make the url dynamic? because it would just show test/profilepage.html no matter who i am looking at, right? Link to comment https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164436 Share on other sites More sharing options...
litebearer Posted January 24, 2011 Share Posted January 24, 2011 yes Link to comment https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164448 Share on other sites More sharing options...
hitokirikensan Posted January 24, 2011 Author Share Posted January 24, 2011 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 https://forums.phpfreaks.com/topic/225496-dynamically-create-user-pages/#findComment-1164504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.