php to create a page and link? [urgently help]

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

Ok, thanks to the guys in ozzu town i have managed to create most of the admin section where i can add members of a team, delete and view them.

I now have the main members page. Ok now i take it i will need to connect to the database again and then view the members. Beside the members i will need a link going to a seperate page of there own with the details they had put in. (put in the admin cp).

The table does not an "ID" column but does have a "Username" column and they are all different.

What i want to do
Right, i want this... As soon as i add a member, or the members add themselves i want the record to be added straight away on the "members.php" page. Of course by using the same thing as i done in the admin cp.
But then i want a link beside them (unique) which then takes them to there own page with all the details they put in the registration form.

I take it i will end up with a page like... members.php?member={$username}?

How can i then have a link below each page saying "If you are this member, and would like to edit your profile then click here?"

Please do help.
Regards
Nem
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

Any ideas or tutorials?
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Ok, what I think you are wanting to do is show something like a profile. If this is so then you can do something like this:
PHP Code: [ Select ]
if($_GET['member']>0) {
 
     $user = mysql_query("SELECT * FROM `members` WHERE `id` = '$_GET[member]' LIMIT 1");
 
     $user = mysql_fetch_object($user);
 
     echo "You are viewing member: $user->username";
 
     echo "Other information you may have.";
 
} else {
 
     //show member list
 
}
  1. if($_GET['member']>0) {
  2.  
  3.      $user = mysql_query("SELECT * FROM `members` WHERE `id` = '$_GET[member]' LIMIT 1");
  4.  
  5.      $user = mysql_fetch_object($user);
  6.  
  7.      echo "You are viewing member: $user->username";
  8.  
  9.      echo "Other information you may have.";
  10.  
  11. } else {
  12.  
  13.      //show member list
  14.  
  15. }

Then if you only want the link to show for editing the profile, you can have a cookie set once the member logs in and have something like this:
PHP Code: [ Select ]
if($_COOKIE['member_id'] == $_GET['member']) {
 
     echo "<a href=\"profile.php?act=edit\">Edit your profile</a>";
 
}
  1. if($_COOKIE['member_id'] == $_GET['member']) {
  2.  
  3.      echo "<a href=\"profile.php?act=edit\">Edit your profile</a>";
  4.  
  5. }

I'm pretty sure that is what you wanted. Hope that it helped.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

i got to eat but i be back to reply properly in a min
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

he has no idea so you would have to use the username, and i would just make it a profile.php?member=[username]
inside of profile.php you would have some layout to display the information

PHP Code: [ Select ]
 
//cookie stuff if you are using it
 
if(!$username) {
 
   $username = $usercook;
 
   $password = $passcook;
 
}
 
setcookie("usercook", "$username");
 
setcookie("passcook", "$password");
 
 
 
 $result = @mysql_query("SELECT * FROM members WHERE username = '$member");
 
  $row = mysql_fetch_array($result);
 
  extract($row);
 
 
 
echo("
 
/*if you are using cookies and the person view the profile is loged in as the profile user it will display a link to let the person edit the profile*/
 
if($usercook == $username) {
 
echo("<a href='main.php'>Click here to edit your profile</a>");
 
}
 
<table>
 
<tr>
 
<td>username:$row[username]</td>
 
</tr>
 
<tr>
 
<td>something:$row[something]</td>
 
</tr>
 
<tr>
 
<td>something2:$row[something2]</td>
 
</tr>
 
</table>
 
");
 
 
  1.  
  2. //cookie stuff if you are using it
  3.  
  4. if(!$username) {
  5.  
  6.    $username = $usercook;
  7.  
  8.    $password = $passcook;
  9.  
  10. }
  11.  
  12. setcookie("usercook", "$username");
  13.  
  14. setcookie("passcook", "$password");
  15.  
  16.  
  17.  
  18.  $result = @mysql_query("SELECT * FROM members WHERE username = '$member");
  19.  
  20.   $row = mysql_fetch_array($result);
  21.  
  22.   extract($row);
  23.  
  24.  
  25.  
  26. echo("
  27.  
  28. /*if you are using cookies and the person view the profile is loged in as the profile user it will display a link to let the person edit the profile*/
  29.  
  30. if($usercook == $username) {
  31.  
  32. echo("<a href='main.php'>Click here to edit your profile</a>");
  33.  
  34. }
  35.  
  36. <table>
  37.  
  38. <tr>
  39.  
  40. <td>username:$row[username]</td>
  41.  
  42. </tr>
  43.  
  44. <tr>
  45.  
  46. <td>something:$row[something]</td>
  47.  
  48. </tr>
  49.  
  50. <tr>
  51.  
  52. <td>something2:$row[something2]</td>
  53.  
  54. </tr>
  55.  
  56. </table>
  57.  
  58. ");
  59.  
  60.  

this makes it so one page will display everyones profile[/php]
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

do you mean that page will show seperate profiles just by adding "[username] at the end of the url?
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

yep by change the ending it will show a diff profile.... at least if the user is in the database and if you get compliated you can make it so if the user isnt it wont show the profile
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

amazing stuff, only been learning php for 5 days, and created an admin cp :D
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

but, in the dbase there is a username and password bit.

how do i connect to the database so that if they need to log in, the php can check if they both match to go forward to the editing page.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

PHP Code: [ Select ]
 
<?PHP
 
include('http://www.69kilobytes.co.uk/header.php');
 
//cookie stuff if you are using it
 
if(!$username) {
 
    $username = $usercook;
 
    $password = $passcook;
 
}
 
setcookie("usercook", "$username");
 
setcookie("passcook", "$password");
 
 
 
$result = @mysql_query("SELECT * FROM members WHERE username = '$username'");
 
  $row = mysql_fetch_array($result);
 
  extract($row);
 
 
 
echo("
 
/*if you are using cookies and the person view the profile is loged in as the profile user it will display a link to let the person edit the profile*/
 
if($usercook == $username) {
 
echo("<a href='edit_member.php'>Click here to edit your profile</a>");
 
}
 
<table>
 
<tr>
 
<td>username:$row[username]</td>
 
</tr>
 
<tr>
 
<td>something:$row[something]</td>
 
</tr>
 
<tr>
 
<td>something2:$row[something2]</td>
 
</tr>
 
</table>
 
");
 
include('http://www.69kilobytes.co.uk/footer.php');
 
?>
 
 
  1.  
  2. <?PHP
  3.  
  4. include('http://www.69kilobytes.co.uk/header.php');
  5.  
  6. //cookie stuff if you are using it
  7.  
  8. if(!$username) {
  9.  
  10.     $username = $usercook;
  11.  
  12.     $password = $passcook;
  13.  
  14. }
  15.  
  16. setcookie("usercook", "$username");
  17.  
  18. setcookie("passcook", "$password");
  19.  
  20.  
  21.  
  22. $result = @mysql_query("SELECT * FROM members WHERE username = '$username'");
  23.  
  24.   $row = mysql_fetch_array($result);
  25.  
  26.   extract($row);
  27.  
  28.  
  29.  
  30. echo("
  31.  
  32. /*if you are using cookies and the person view the profile is loged in as the profile user it will display a link to let the person edit the profile*/
  33.  
  34. if($usercook == $username) {
  35.  
  36. echo("<a href='edit_member.php'>Click here to edit your profile</a>");
  37.  
  38. }
  39.  
  40. <table>
  41.  
  42. <tr>
  43.  
  44. <td>username:$row[username]</td>
  45.  
  46. </tr>
  47.  
  48. <tr>
  49.  
  50. <td>something:$row[something]</td>
  51.  
  52. </tr>
  53.  
  54. <tr>
  55.  
  56. <td>something2:$row[something2]</td>
  57.  
  58. </tr>
  59.  
  60. </table>
  61.  
  62. ");
  63.  
  64. include('http://www.69kilobytes.co.uk/footer.php');
  65.  
  66. ?>
  67.  
  68.  


parse error: line 18
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Well on line 15 you have ' echo(" ' then you have nothing to follow it, that may be the problem.

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 57 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.