jaisol99 Posted October 18, 2009 Share Posted October 18, 2009 Hi If I have <a href="main_file.php"> How do I send data to main_file.php I have a group of links that are created on the fly and I want to give each link a value so that I can retrieve more info out of my database on individual items. I don't realy want to use forms and buttons / tick boxes etc. I'm looking for something like <a href="main_file.php" VALUE = $_A_Variable> So that I can identify which link was selected. Quote Link to comment https://forums.phpfreaks.com/topic/178128-how-do-i-send-data-using-an-html-link/ Share on other sites More sharing options...
mikesta707 Posted October 18, 2009 Share Posted October 18, 2009 use $_GET if a link was <a href="mypage.php?val=myvalue" ></a> you could access that get variable, like $val = $_GET['val']; echo $val;//myvalue Quote Link to comment https://forums.phpfreaks.com/topic/178128-how-do-i-send-data-using-an-html-link/#findComment-939188 Share on other sites More sharing options...
jacked69 Posted June 5, 2013 Share Posted June 5, 2013 Just to add to the above link. Use <?php session_start(); ?> before the <html> tags. Read this somewhere online if you are using GET. What I did is below, comment please. Totally and very unsecure. So the first web page might be called 1stPage.php and you have a php variable that holds the information you want to pass to your second php page. I called the variable $valueToPass. <?php session_start(); // start session first for transfer of information ?> <html><head><title> </title></head><body> <?php // start php ..... // code here echo '<a href="2ndPage.php?valuePassed='.$valueToPass.'">'. $valueToPass . '</a> '; // so above is a hperlink with a php variable as the link text called $valueToPass. It is what I processed in the 1st page and need to get to the 2nd // page. I assigned the name valuePassed. ... // more code //end of php ?> </body></html> 2nd page has: $valRequested = $_GET['valuePassed']; Worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/178128-how-do-i-send-data-using-an-html-link/#findComment-1434316 Share on other sites More sharing options...
DavidAM Posted June 6, 2013 Share Posted June 6, 2013 session_start is NOT needed for URL parameters ($_GET). It is only required for maintaining values between pages using the $_SESSION super-global. Quote Link to comment https://forums.phpfreaks.com/topic/178128-how-do-i-send-data-using-an-html-link/#findComment-1434499 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.