Sinbad_Sakic Posted November 3, 2008 Share Posted November 3, 2008 Hi to everyone Here's my code: first_page.html <html> <head> <title>First</title> </head> <body> <a href="second_page.html">Link 1</a><br /> <a href="second_page.html">Link 2</a><br /> <a href="second_page.html">Link 3</a> </body> </html> second_page.html <html> <head> <title>Second</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <label> <select name="link" id="link"> <option value="Link 1">Link 1 was selected</option> <option value="Link 2">Link 2 was selected</option> <option value="Link 3">Link 3 was selected</option> </select> </label> </form> </body> </html> How to connect these two pages, so when I click on Link 2 on the first page, the second pages opens and the Link 2 was selected is choosed? Thank you in any case Batric Quote Link to comment https://forums.phpfreaks.com/topic/131163-solved-pass-information-through-link/ Share on other sites More sharing options...
Adam Posted November 3, 2008 Share Posted November 3, 2008 Firstly you'll need to use the PHP extension on the file (unless you have configured your server to parse html files?) Then you'll need to pass a parameter through the URL, like so: <a href="second_page.php?link=1">Link 1</a> .. Doesn't have to be "link=1". Then on second_page.php you'll need to use some PHP to decide which option to select, quick and simple way of doing it.. <select name="link" id="link"> <option value="Link 1"<?php if ($_GET['link'] == 1) { echo ' selected'; } ?>>Link 1 was selected</option> <option value="Link 2"<?php if ($_GET['link'] == 2) { echo ' selected'; } ?>>Link 2 was selected</option> <option value="Link 3"<?php if ($_GET['link'] == 3) { echo ' selected'; } ?>>Link 3 was selected</option> </select> $_GET['..'] is used to return values sent in the URL, so $_GET['link'] holds the value of '1' if in the URL you had: 'link=1' .. Make sense? Adam Quote Link to comment https://forums.phpfreaks.com/topic/131163-solved-pass-information-through-link/#findComment-681010 Share on other sites More sharing options...
Sinbad_Sakic Posted November 3, 2008 Author Share Posted November 3, 2008 It works! Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/131163-solved-pass-information-through-link/#findComment-681021 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.