PHP – $_GET to Send Variables in Hyperlinks

You can send Variable Names and Values using hyperlinks to PHP Scripts. This is an easy way to send variable data, but is incredibly insecure.

To send a variable to a PHP script add ?variable_name=variable_value to the script link. You can send multiple variables by using & such as get.php?variable1=value1&variable2=value2




$color = $_GET['color'];
$size = $_GET['size'];

echo "<a href='./get.php?color=blue'> Change Color to BLUE </a><br>";
echo "<a href='./get.php?color=red'>Change Color to RED</a><br><br>";

echo "<a href='./get.php?color=blue&size=20'> Change Color to BLUE and Size to 20</a><br>";
echo "<a href='./get.php?color=red&size=40'>Change Color to RED and Size to 40</a><br><br>";

echo "<h1>Example of Text Output</h1>";

echo "<p style='color:".$color.";font-size:".$size."px;'>This is the output text from GET hyperlinks</p>";


Be the first to comment

Leave a Reply