eaglehopes Posted May 29, 2022 Share Posted May 29, 2022 (edited) Hi to all ! I have a web page whose main page is index.php I try to use passing data inside embedded URLs : my code is below : <!DOCTYPE html> <html> <body class="background" > <div> <a class="button" href="./index.php?page=home" target="_self">Home</a> <a class="button" href="./index.php?page=about" target="_self">About</a> <a class="button" href="./index.php?page=blog" target="_self">Blog</a> </div> <div> <?php include 'db.inc'; echo "page selected is ". $page ."\n"; // if user request blogs- then show blog menu here if ( strcmp($page,"blog")==0) { // get new menu from file echo "YEKEKE ". $page ."is blog"; if( include ('./pages/blog/categories/categories.php') == TRUE ) { // do nothing } else { echo "Page Load error..."; } } else { echo "try out"; } console.log($page."is blog"); ?> </div> </body> </html> However, it does not work since I could not get $page variable correctly, I get $page as blank variable. Why, where is my mistake? Any help is appreciated. Edit : I try to do that : 1. user click link in index.php page 2. get the new page inside index.php with sended value of the $page variable... Edited May 29, 2022 by eaglehopes Quote Link to comment https://forums.phpfreaks.com/topic/314862-problem-in-passing-data-with-embedded-link/ Share on other sites More sharing options...
Solution eaglehopes Posted May 29, 2022 Author Solution Share Posted May 29, 2022 Ok ! I found the answer in answer . It says that, I forgot to get the variable passed by using $_GET["page"] . So below code solved my problem $page=$_GET["page"]; Quote Link to comment https://forums.phpfreaks.com/topic/314862-problem-in-passing-data-with-embedded-link/#findComment-1596812 Share on other sites More sharing options...
requinix Posted May 29, 2022 Share Posted May 29, 2022 There used to be a time, long ago, where $page would be created automatically. If whatever resource you're learning from expects that to be the case and doesn't use $_GET/POST then you need to find another resource to learn from. Quote Link to comment https://forums.phpfreaks.com/topic/314862-problem-in-passing-data-with-embedded-link/#findComment-1596816 Share on other sites More sharing options...
eaglehopes Posted May 30, 2022 Author Share Posted May 30, 2022 16 hours ago, requinix said: There used to be a time, long ago, where $page would be created automatically. If whatever resource you're learning from expects that to be the case and doesn't use $_GET/POST then you need to find another resource to learn from. Thanks requinix ! It happens exactly as you said : my resource is a book and it says that "PHP initialize $page variable automatically". It also says that use $HTTP_GET_VARS["varname"] to get the sended variable ! So I had to research extra documents to find that all of them depreceated. Time to change resource as you said :) Quote Link to comment https://forums.phpfreaks.com/topic/314862-problem-in-passing-data-with-embedded-link/#findComment-1596831 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.