Hi People. Wonder if you can help me out.
I am very new to php so be gentle.
I have built a rather simple database of postcodes and some information regarding them.
I have also built a php page called postcode.php
When someone enters a postcode into a form, postcode.php goes and looks at the database and if the postcode entered into the form is in the database then it returns the information about that postcode. SIMPLE YES?
Everything is working fine and dandy, EXCEPT the url in the address bar always remains the same ie http://www.mysite.com/postcode.php
I wonder if anyone can help me or point me in the right direction of how i can have a unique id for each page? ie http://www.mysite.com/postcode.php?id10 etc
I am assuming this is very simple, but i have searched my butt off and cannot find anything usefull about this.
Many thanks.
How do i get unique urls?
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: How do i get unique urls?
Does your form use the POST method? If so, the address bar will remain the same (assuming the action is to submit to the same page)
Why do you want to show the id in the address bar?
Why do you want to show the id in the address bar?
Re: How do i get unique urls?
That ?id10 bit isn't a unique URL, it is a way to pass data to your php page. Unless you want to pass data variables via the URL you don't need to worry about it.
Typically your code will generate a link with the ?id=10 (you need the equals sign to make it easier). Then in your code you can parse the URL with $value=$_GET['id']; and it will extract the value 10. Here's a short tutorial http://www.tizag.com/phpT/postget.php
Typically your code will generate a link with the ?id=10 (you need the equals sign to make it easier). Then in your code you can parse the URL with $value=$_GET['id']; and it will extract the value 10. Here's a short tutorial http://www.tizag.com/phpT/postget.php
-
merylvingien
- Forum Newbie
- Posts: 12
- Joined: Mon Sep 07, 2009 9:05 am
Re: How do i get unique urls?
The only reason i want unique id's is so i can add each url to the sitemap.xml so google can crawl each page.
If i just submit postcode.php to google it wont be able to index all the different info that is stored in the database?
If i just submit postcode.php to google it wont be able to index all the different info that is stored in the database?
Re: How do i get unique urls?
Well I don't think google will attach much meaning to a link that has ?id=10 versus ?id=20. You'll have to design a sitemap that has more distinctive information for each generated link. But that is a different topic.
You can always make links to your page with ?id=10 or whatever. Your php code will just ignore the data unless you put the $_GET in there to process the URL data. And if google crawls all those links and finds the page isn't any different it's probably going to down grade your site.
You can always make links to your page with ?id=10 or whatever. Your php code will just ignore the data unless you put the $_GET in there to process the URL data. And if google crawls all those links and finds the page isn't any different it's probably going to down grade your site.
-
merylvingien
- Forum Newbie
- Posts: 12
- Joined: Mon Sep 07, 2009 9:05 am
Re: How do i get unique urls?
I think i have it working, i have changed the form to the GET method and changed the $value=$_GET["value"]; in the postcode.php and i am now getting something near to what i need.
If i cut and paste a link into a new browser the results are the same, so i guess i could enter these in the sitemap and all should be grand.
Many thanks for your help, no doubt i will be back later asking more silly questions
If i cut and paste a link into a new browser the results are the same, so i guess i could enter these in the sitemap and all should be grand.
Many thanks for your help, no doubt i will be back later asking more silly questions