PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 21st, 2012, 07:33 AM
szkgroove szkgroove is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 7 szkgroove User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 57 m 28 sec
Reputation Power: 0
PHP-General - How to get more data in URL

Hello,
I have product page that returns url like this
127.0.0.1/page/pitem_buy.php?id=12559
How can I, using PHP get more data in URL like product name.
I do not need rewrite or SEO friendly URL, just need beside id, product name in any format.
I appreciate any help, thanks

Reply With Quote
  #2  
Old November 21st, 2012, 07:46 AM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,886 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 22 m 27 sec
Reputation Power: 581
Passing parameters in the URL uses the get method in PHP. You can add any additional parameters you want by separating them with '&'. So your URL might look like:

127.0.0.1/page/pitem_buy.php?id=12559&productname=some%20name

Note the use of %20 to represent a space (you could also have used '+'). It is important to not use reserved characters within parameters you are trying to pass. When generating the URL in PHP you should pass that part of the URL string through 'urlencode'. If generating the URL manually then you should look at this to make sure you don't get unexpected results.

As an aside, keep in mind that anyone can manipulate URLs to try to hack your site. Never put any sensitive data into a URL nor trust any strings in the URL (validation checking is critical to security when using the get method).
Comments on this post
szkgroove agrees: Great, Thanks
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Last edited by gw1500se : November 21st, 2012 at 07:49 AM.

Reply With Quote
  #3  
Old November 21st, 2012, 08:20 AM
szkgroove szkgroove is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 7 szkgroove User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 57 m 28 sec
Reputation Power: 0
WORKS, thanks again

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - How to get more data in URL

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap