I have this
<a href='#?title=sample&url=sample.com'></a>
on the same page I put
$title = $_GET['title'];
$url = $_GET['url'];
but it doesn’t passes the values.
what’s wrong with the code?
help please!
NOTE:
I wanted not to reload the page that’s why i put # because at the later part I will call a javascript function onclick
here’s the function call onclick
<script language="JavaScript">
function overlay() {
el = document.getElementById("overlay");
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
</script>
where the element “overlay” must contain the value of
$title = $_GET['title'];
$url = $_GET['url'];
I think you need to remove the hash (#) from your URL. If you need the hash tag in your URL, it must at the end of the URL:
If you place the hash before the querystrings like you have, you are basically telling the browser to find an element/target called “?title=sample&url=sample.com”, which it probably won’t like.
For your updated question:
I think you are better off using the link to call your javascript function, instead of adding querystring values to you URL like you have. For PHP to be able to get these values, the page would have to reload/send request to the server. If you do not want the page to reload, I suggest you change your link to this:
and then have a function:
This means you can get the values you wanted without refreshing the page.