I want to pass a variable along with the link on a button click, while using href. can anyone tell me the exact syntax or if it is even possible? i want to do something like this: href="link+variable" so that i can extract the variable and use it on the "link" which will open.
Yes it is possible by doing the following
site 1
<input type="button" onClick="window.location='http://example.com?var=<?php echo $var ?>'">
On the recieving site use the following:
site 2
<?php
$var = $_GET['var'];
?>
The variable you sent is store in $var in site 2
Do you mean passing a value as a parameter?
<a href="page.php?value_key=some_value">Link</a>
Then in PHP
if(isset($_GET['value_key'])){
$var = $_GET['value_key']; //some_value
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With