Jump to content

[SOLVED] Member Pages /member-profile?id


daveoffy

Recommended Posts

I want to make it so each member has a member/profile page that others can view.

 

I know this requires a .htaccess and a PHP page in member-profile.php but can't seem to get it to work and I can't find anything online to help me. Can someone please point me in the right direction so I can get this working.

Link to comment
https://forums.phpfreaks.com/topic/135257-solved-member-pages-member-profileid/
Share on other sites

RewriteRule /member/(.*)$ member-profile.php?member=$1

 

Roughly.. my syntax is probably off.

 

Only use (.*) if you have no character limitations. If all users are purely alphanumeric and you want to (and should) enforce that.. use this:

 

RewriteRule /member/([a-zA-Z0-9])$ member-profile.php?member=$1

I am using RewriteRule /member/([0-9])$ member-profile.php?member=$1 because it is going to display by the member_id. How will I make it so it shows information of that member when people go to member-profile.php?member=$1 or whatever the member_id is?

I got it. For anyone looking how to do this also I will show you below

 

.htaccess

Options +FollowSymlinks
RewriteEngine on
RewriteRule /member_id/([0-9])$ member-profile.php?member_id=$1

change /member_id/ and ?member_id to what in the database you are using for the URL's of the members

 

Than I used member-profile.php for the page so the code is below

<?php
{Connecting to Database stuff}
$sql = "select * from members WHERE member_id = '{$_GET['member_id']}'";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result))
echo "{$row['member_id']}";
?>

 

I think you can edit that for your own use.

Don't forget to validate that.

 

You can do that easily, since you're pulling data by an integer..

<?php
if(ctype_digit($_GET['member_id'])):
   // do something
else:
   // Fail - it's not an integer value!
endif;

 

Addendum:

 

You don't need a while loop if you're only fetching 1 row of data.

Don't forget to validate that.

 

You can do that easily, since you're pulling data by an integer..

<?php
if(ctype_digit($_GET['member_id'])):
   // do something
else:
   // Fail - it's not an integer value!
endif;

 

Addendum:

 

You don't need a while loop if you're only fetching 1 row of data.

 

expanding on security, you should also use mysql_real_escape_string()

If you learn session's then all them get's go to bed...

 

it grate using all the php functions and mod_rewrite apache function but you only needed to use a

session for the members id finished....

 

ill be honest when using mod_rewrite you really need to understand seo concept aswell ..........

 

Only expressing my felling sorry.......

 

 

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.