Scion Posted July 11, 2007 Share Posted July 11, 2007 Hi, I have a client who wants to make member profile pages for each registered website member. How would I go about automatically generating a profile page for each member, which can be updated when a member edits his/her information? Any help is greatly appreciated Quote Link to comment Share on other sites More sharing options...
marcus Posted July 11, 2007 Share Posted July 11, 2007 Well the profile itself would just contain basic information about the account, and the user profile that the user has designed themselves. So basically you want to have some main fields in your database: -username -age -email [other info they would show on their page] then their actually profile make a text field named "description" Say you wanted to have the profile URL look something like: /users/profile:username MOD Rewrite does the trick there: [put into your .htaccess] RewriteEngine On RewriteRule ^users/profile\[^*]*)$ /profile.php?username=$1 [L] Then profile.php would consist of something as such: <?php $username = $_GET[username]; //you can protect it later $sql = "SELECT * FROM `users` WHERE `username`= '$username'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "<b>This user does not exist!</b>\n"; }else { $row = mysql_fetch_assoc($res); echo "<table border=0 cellspacing=3 cellpadding=3 width=600>\n"; echo "<tr><td align=center>Welcome to <b>$username's</b> profile</td></tr>\n"; echo "<tr><td valign=top>$row[description</td></tr>\n"; echo "<tr><td valign=top>$username's Stats:<br>Age: $row[age]<br>E-Mail: <a href=\"mailto:$row[email]\">$row[email]</a></td></tr>\n"; echo "</table>\n"; } ?> Now of course you could easily edit it to make it your own. Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 11, 2007 Share Posted July 11, 2007 Mod rewrite is so powerful, where is the best place to learn it at? Quote Link to comment Share on other sites More sharing options...
marcus Posted July 11, 2007 Share Posted July 11, 2007 Any google search could give you a nice tutorial, if you want something to do it for you: http://www.mod-rewrite-wizard.com/ 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.