If you want to make use of $_GET
then you should use a ?
instead of #
. The ? symbol is the indicator for a GET, not the #.
So simply change your URL structure to:
<script>
window.location.href = "signup.php?year=" + myyear;
</script>
and then, as you already did, grab the value with the GET.
<?php
if(isset($_GET['year'])){
$year = $_GET['year'];
}
?>
If you want to use more parameter, use the &
symbol to separate them. You can add as many as you want, you just have to follow the `&key1=value1&key2=value2? structure and you can expand it as long as you want. Example:
<script>
window.location.href = "signup.php?year=" + myyear&month=5;
</script>
Now you could do:
<?php
if(isset($_GET['year'])){
$year = $_GET['year'];
$month = $_GET['month']; // Would assign 5 to month.
}
?>