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! Quote Link to comment 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']; ?> Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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']; ?> Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 24, 2011 Share Posted January 24, 2011 yes Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.