Click here to Skip to main content
15,348,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi, can some one please help me for making url like this

somesite.com/index.php?id=111111&name=sam

i know it's something like this

PHP
<?php

$id = $_GET['id'];

?>


but how do i make it to get name "sam" from that id 111111 when i go to that url ?

Thanks.
Posted

1 solution

As you have done for the id, like this:
$name = $_GET['name'];

Read this: PHP 5 Form Handling[^]. Look for the method='get' in the form tag example.
   
v2
Comments
Member 10749093 21-Jan-15 21:42pm
   
hey Peter, can you tell me how do i make it like for example, there's many links on the page but not displaying until i put the id on url. so if i put id on url then link must show up in body of the page. hope you understand and thanks.
Peter Leow 21-Jan-15 22:04pm
   
Not clear. Can you show some code and html pages and how you want to navigate between them?
Member 10749093 21-Jan-15 22:15pm
   
if(isset($_GET["id"]) && trim($_GET["id"]) == 'hi')
Member 10749093 21-Jan-15 22:16pm
   
look at that code, it has only 1 "id" i want to make it like this somesite.com/index.php?id=111111&name=sam
Not like this somesite.com/index.php?id=111111
Peter Leow 21-Jan-15 22:34pm
   
this url somesite.com/index.php?id=111111&name=sam has 2 query strings id="111111" and name="sam"
To capture them on the server side, do this:
if(isset($_GET["id"]) && trim($_GET["id"]) == '111111' && isset($_GET["name"]) && trim($_GET["id"]) == 'sam' ) {
// if id = "111111" and name="sam"
// then do something
}
Member 10749093 21-Jan-15 22:54pm
   
i don't really know how to thank you. Thanks you very very much Peter it worked perfectly. i been searching for this solution like about a week. and now you solved this for me. Thanks again.
Peter Leow 21-Jan-15 23:58pm
   
You are welcome.
Member 10749093 22-Jan-15 0:03am
   
hey peter, is there anyway i can message you? i have 1 more question its about same this question almost
Peter Leow 22-Jan-15 0:14am
   
Post it as a new question so that everyone can help.
Member 10749093 22-Jan-15 0:27am
   
http://www.codeproject.com/Questions/868258/PHP-auto-add-query-strings-in-a-page this is my question link please answer it if you can

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900