Need some help with some basic stuff

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jm999
Forum Commoner
Posts: 28
Joined: Tue Aug 29, 2006 11:58 am

Need some help with some basic stuff

Post by jm999 »

I have posted a few times about a site I'm currently building. Basically its a gift registry where people can sign up and add links to products to their personal registry page. I have the database set up and everything is working properly. Now I need to set up the page where visitors can view the registries. I have no idea how to go about it. Could anyone help me get going in the right direction?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Something to start you off: viewtopic.php?t=24556&highlight=database
jm999
Forum Commoner
Posts: 28
Joined: Tue Aug 29, 2006 11:58 am

Post by jm999 »

Thanks for the reply. I guess I should have been more specific. I have already set up forms to register and insert the information for the individual registrants. Now I need to create the page where a visitor can look at individual registries. I'm not sure how to go about that. I'll have a search feature where a visitor can search for a registrant by first and last name, but I need a page to link to that will display their registry.

The registrant also invites guests via email automatically upon registration. The email will contain a link to their registry for their guests to go to. I'm just at a loss as to how I create that page.
jm999
Forum Commoner
Posts: 28
Joined: Tue Aug 29, 2006 11:58 am

Post by jm999 »

In a previous post I was told that the page would be something like "http://www.thesite.com/view_registry.php?userid=1".

What exactly does the view_registry page need to do in order to recognize the "userid=1" ?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

jm999
Forum Commoner
Posts: 28
Joined: Tue Aug 29, 2006 11:58 am

Post by jm999 »

Ok, I looked at that. How can the view_registry page take the "1" and put that into a variable in order to display the information?

I just want the page to get the information based on the userid in the url. Is that possible? Or is the variable already established by putting in the "?userid=1" ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There is a variable established when you have ?userid=1 in the URL (given correct placement) for userid. As jayshields points out, it would be in the $_GET superglobal.
jm999
Forum Commoner
Posts: 28
Joined: Tue Aug 29, 2006 11:58 am

Post by jm999 »

Thanks for the tips. I got it now. So adding the "?userid=1" allows you to access the "1" with $_GET['userid'], right?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Correct. Before you stick that straight into your query, though, be aware that the user can stick anything into that variable, including quotation marks. Always "sanitize" your variables with mysql_real_escape_string.
jm999
Forum Commoner
Posts: 28
Joined: Tue Aug 29, 2006 11:58 am

Post by jm999 »

Awesome. I finally feel like I'm getting somewhere. Thanks a bunch for all of your help. My next issue is with the search function. People will have the ability to search the registries by first name and last name. This will ultimately bring up multiple registries. How do I link the results to their corresponding userid?
Post Reply