Jump to content

Set Variable on href click?


redgunner

Recommended Posts

You'd define it within the query string

<a href="file.php?somevar=1">Link</a>

You'll use the GET super global for getting the variables from the query string, for this example you'd use the variable $_GET['somevar'] within file.php

 

<?php

echo 'Variable is set to: ' . $_GET['somevar'];

echo '<p>Lets see what is in the $_GET superglobal: <pre>' . print_r($_GET, true) . '</pre>';

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.