PHP link
Moderator: General Moderators
PHP link
I have two problems.
1. I want to put a variable into a link. Eg. http://www.forum.example.com/index.php?showuser=[b]$id[/b]
2. I know this needs to be in the database forum, but it's related to my 1st issue. I want to query my mySQL database to get the id of the user who is logged in. EG. I am logged in as example. I want example to be shown the link http://www.forum.example.com/index.php?showuser=1 because he has an id of 1
Any suggestions?
1. I want to put a variable into a link. Eg. http://www.forum.example.com/index.php?showuser=[b]$id[/b]
2. I know this needs to be in the database forum, but it's related to my 1st issue. I want to query my mySQL database to get the id of the user who is logged in. EG. I am logged in as example. I want example to be shown the link http://www.forum.example.com/index.php?showuser=1 because he has an id of 1
Any suggestions?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Code: Select all
<?php
$var = 'in Canada...';
echo 'I slept near a bear ' . $var;
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I am not sure. I used this code: http://php.about.com/od/finishedphp1/ss ... n_code.htm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I can get the code to work fine. I want to be able to use a variable in a link. The variable comes from a mySQL database and is on the same row as the username of the member. It is the member id and I want to use it to show a members profile page by the member clicking on it. I want only the member to be able to access it.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
So where in the code does the app know to use this id? What I am getting at is the only way to offer this link for the person that is logged in is to know who is logged in. Typically that is done with sessions. If you have session data, then you can easily add a session var with the logged in users ID to be used as a regular var later in the code.mademokid wrote:The variable comes from a mySQL database and is on the same row as the username of the member.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Sorry, I think you and I are going around in circles. Somewhere in your code that you are trying to extend there needs to be something, codewise, that will tell the app that someone is logged in. Otherwise, there is no chance of doing anything with any logged in user data because the app will not know that someone is logged in.
The part of the code that keeps track of someone being logged in is the part of the code you want to leverage to get the id of who is logged, at which point you can use their information for all sorts of other goodies.
The part of the code that keeps track of someone being logged in is the part of the code you want to leverage to get the id of who is logged, at which point you can use their information for all sorts of other goodies.