Of course that URL was an example, but I was wondering if someone can explain to me how to make webpages that end like that. (And also how to create links to those kind of pages.)
Thank you!
[Solved] Webpage URLs that end in ".php?blah=5"
Moderator: General Moderators
[Solved] Webpage URLs that end in ".php?blah=5"
Last edited by Jeefo on Thu Aug 25, 2005 5:17 pm, edited 1 time in total.
make a form
you can create that kind of URL in code, but the normal way to see it is the response to a form being sent back from a browser. So which thing are you trying to do?
Re: make a form
Let's say my website has a shop. My URL is http://www.mydomain.com. So I click on the shop link, which goes to http://www.mydomain.com/items.php. But my shop is divided into different genres of items. I click one genre, and it goes to http://www.mydomain.com/items.php?=2. But if I go to another genre, it goes to http://www.mydomain.com/items.php?=3. I did my best explaining. Hope that helped.vulcan_ wrote:So which thing are you trying to do?
Try this one
Well i m putting the code.
i don't know i should use this tag or not and if it is not acceptable please let me know. i will edit my post
let's suppose you have three files
1.test.html
2.test1.html
3.test1.html
in test.html write this code
<a href="test.php?id=2">Click me </a>
in test1.html write this code
<a href="test.php?id=3">Click me </a>
in test.php do something to use this value.
When you pass this value ur passing the value from client to browser and the server will use get method to get this value.if You are using forms then server will use post method.
I hope this will help
i don't know i should use this tag or not and if it is not acceptable please let me know. i will edit my post
let's suppose you have three files
1.test.html
2.test1.html
3.test1.html
in test.html write this code
<a href="test.php?id=2">Click me </a>
in test1.html write this code
<a href="test.php?id=3">Click me </a>
in test.php do something to use this value.
When you pass this value ur passing the value from client to browser and the server will use get method to get this value.if You are using forms then server will use post method.
I hope this will help
file1.php
file2.php [newb version--easier to explain]
file2.php [the way it should be]
Or, you might want to read a file based on what was entered.
It's basically used so you don't have to repeat yourself or when you submit a form. Most forms will be post, though (you don't see it in the URL).
Take this page, for example. "viewtopic.php?t=34638"
This is viewtopic.php reading thread 34638. Without the variable at the end, there would have to be a physical page for each thread here (e.g. viewtopic34638.php).
Hope that helps.
Code: Select all
<a href="e;file2.php?code=1"e;>One</a>
<a href="e;file2.php?code=2"e;>Two</a>
<a href="e;file2.php?code=3"e;>Three</a>Code: Select all
<?php
if ($_GET['code'] == 1) {
// do this
}
elseif ($_GET['code'] == 2) {
// do this
}
elseif ($_GET['code'] == 3) {
// do this
}
else {
// do this
}
?>Code: Select all
<?php
if (isset($_GET['code'])) {
switch $_GET['code'] {
case 1:
// do whatever
break;
case 2:
// do whatever
break;
case 3:
// do whatever
break;
default:
// a code was entered, but it wasn't 1, 2 or 3.
}
}
else {
// default display
}
?>Code: Select all
<?php
$valid = range(1,3); // same as array(1,2,3);
if (isset($_GET['code']) && in_array($_GET['code'],$valid)) {
require $_GET['code'].'.php';
}
else {
// default page
}
?>Take this page, for example. "viewtopic.php?t=34638"
This is viewtopic.php reading thread 34638. Without the variable at the end, there would have to be a physical page for each thread here (e.g. viewtopic34638.php).
Hope that helps.
for your situation I'd avoid using POST however...for shopping sites et al, I find it better practice to use URL vars so one of your visitors could find a product, then send a link to one of their friends etc so they can see what the item is w/o having to drill any deeper into the site.Skara wrote: Most forms will be post, though (you don't see it in the URL).
it makes for a much better experience for visitors to be able to just copy and paste a url to others or even save it for later viewing.