Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Obtaining and display profile ID's in php?
So I'm looking to create a link located on the homepage, the link will be, for example "www.mysite.com/profile.php?id="
Now what I want to be able to do is that when a user logs in, they are able to click on a their profile link below, and have the "id=" taken from the database and inserted into the link so that the user can then view their profile.
I think i'm going along the right lines with the code but I can't remember if I need to concatenate when displaying the link "www.mysite.com/profile.php?id=$id".
I've tried concatenating but the code editor doesn't seem to recognise it.
Wonder if I shall bump into Gitlez on this question!
Here's the code.
EDIT:
I know it's not the best way, but could you answer the question please instead of telling me it's not the best way....
3 Answers
- GitlezLv 68 years agoFavorite Answer
Hey Will, (way to call me out! :) ... Always happy to help)
First off, here is the working example (Given the information at hand).
With Comments: http://pastebin.com/UJb4UMc1
Without Comments: http://pastebin.com/pDAgwqUR
Although I placed a lot of the information in the comments of the script, I want to go over one crucial skill missing; HTML.
PHP has tranformed and evolved for many years, as with the meaning of the acronym PHP. It first started out as Personal Hypertext Processor, then became Pre-Hypertext Processor and now simply Hyperstext Pre-Processor (yes, the acronym is now broken :) ). The point is, that no matter how PHP has evolved, it has always been, at it core, a hypertext processor. As we all should know HTML is an acronym for HyperText Markup Language. Your HTML was flawed in many ways. It order for me to comment with the necessary information to correct your issues, I would need to write a short book. This may come off as insulting, but I say it in hopes that you learn and become better.
We all should hope for more people to learn the languages of my people. With that I hope you spend a day, backtrack and relearn HTML. Learn it well. It will only take a day or two, but it will help you immensly. Build an entirely HTML, 5 page site, with a contact form (without the PHP for now). Write it all by hand, no programs. Use a couple of images from Google, don't worry about copyright, as you won't be publishing the site, simply using it as a learning tool. Next, re-write the site with PHP. seeing that different ways PHP was initially designed to help make HTML easier to write and expand. That should take you 1-2 days again. On the last day, attempt to write the processing for the contact form. That was the next step PHP took, so it's a good idea for you to follow it as well. Total time, max 5 days. If it takes you longer, so what, you'll have the skills at the end.
You'll have a finished site to reference when you're done. You'll have that sense of accomplishment, twice, when you're done. It will help keep you motivated on your next project. Lack of motivation is why most newbies have tons of half finished projects.
If you want, you can send me the pages ( one set for just html, I'll send some notes, then the PHP can start). Or send me your questions, and I'll walk you through the process. Either way, I think you should stop the project you're on now, and restart the learning process.
Imagine it like building a building, if you don't have a strong, well thought out base, the building won't be able to go as high and won't be strong enough to support anything.
I wish you the best and let me know what I can do to help.
Cheers,
Gitlez
- ?Lv 78 years ago
Not the best way. You are far better setting a session variable for user id and using that to verify the user on every page once they are logged in. That way if another user sees their id and tries to use it they will get thrown out, and you can write a page denying access. But it also hides the ID from anyone watching them on the site. Then one profile page can use the id to retrieve data and build the page according to the user.
- Anonymous8 years ago
To concatenate in that form, use "yoursite.com/profile?id=".$userid
I am assuming you store the id you got from the database into the variable userid. Do not quote the variable with it or else you will get an error.
I was working on something like this awhile ago.