asmith Posted November 30, 2007 Share Posted November 30, 2007 i want to make some links, to some tables. each link goes to one table name, so when i click on each link , a page opens that show the content of that table. how can i do it with php ? just need some tips how ot begin it . thanks Quote Link to comment Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 I would create links like table.php?table=tablename And then your PHP code uses GET to get the tablename, and based on that, you can do your seperate queries and output them. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 till today i was always working with POST , think it's time to take a bite of GET ! I would create links like table.php?table=tablename these addresses i always see on sites address bar, i don't know how they works, anywhere to start with ? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 There are quite a few threads here in the last few days about them. You should be able to find some posts with examples. If not, post a follow up and I'll write something up for you. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 thanks ,but what keywords i search ? GET ? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 $_GET Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 ?!?! still didn't find it ... :-\ (BTW why search results are around 2003 ? ) Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted November 30, 2007 Share Posted November 30, 2007 GET is the same as POST. Except GET is seen as its carried in the address bar. If a file name is followed by a question mark then anything after that is considered as a query string. A query string holds a collection of variables. A variable is set in the following format: file.php?var1=value1 So in the above example a variable is being set (var1) with a value (value1). To have more than one variable you'll separate them with an ampersand (&) eg: file.php?var1=value1&var2=value2 In order to get the variables from the query string in file.php you'd use $_GET. So to get var1 you'd use $_GET['var1'], for var2 you'd use $_GET['var2'] So if you ran the following script with the following url: file.php?var1=value1&var2=value2 <?php echo $_GET['var1'] . '<br />'; echo $_GET['var2']'; ?> You should get the following out put: value1 value2 There are few precautions to make when handling GET data. As it is seen within the browser it can be easily changed by the user so it is important to validate any data coming in form GET, so if a variable is only supposed to contain a number use is_numeric to check to see if that variable is actually a number. Second of all do not pass sensitive information in the url such as passwords as any one within the view of seeing the browser will be able to read the contents of the address bar. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 ahhh good explanation ! i got the whole point ! thanks a bunch ! btw do i have other choices than using get for this thing ? Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 by validating the get input, like the "is_numeric" you said, there's no worring about the data may be type by user ?? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 Yes, it is a concern, which is why you want to validate it. by validating the get input, like the "is_numeric" you said, there's no worring about the data may be type by user ?? Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 another thing, this get we talked about , is all in php ? i mean other program languges have something like this ? for example can a asp page look like : page.php?var1=value or this type of line is only for php ? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 I dont know ASP, but I'm sure it uses something similiar. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 http://www.phpfreaks.com/tutorials/34/0.php it has said about changing the type of a php file to another , so it would make a "hacker" wrong or confused.... following the above, if i use for example .ttt for my pages, then a hacker see file.ttt?val=aaa couldn't he by that "Get style" line find out the the page has written in php ? Quote Link to comment Share on other sites More sharing options...
asmith Posted December 1, 2007 Author Share Posted December 1, 2007 i just checked some asp sites, they use exactlly like php , ? after site name, and uses = , and & ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.