I am newbie to web programming and working on web application development(first project) where i have some text on page and after clicking this text i want to pass some fixed text to other page in PHP as explained here
Page1
<html>
<head>
</html>
<body>
<a href="#" value="fixed text">some text </a>
</body>
</html>
Page2 should be able to get value when i click on page1. How can i implement it?
You should pass arguments with url:
<a href="xyz.php?value=fixed text">some text </a>
And in the xyz.php
or what ever file name for php:
<?php
$value = ! empty($_GET['value']) ? $_GET['value'] : '';
?>
Reference: PHP's $_GET
Whatever data you have in url query string. e.g. xyz.php?par1=one&par2=two&par3=three
You get key value pairs in $_GET
.
So, you will get
$_GET
as
array(
'par1' => 'one',
'par2' => 'two',
'par3' => 'three'
);
page 1
<html>
<head>
</html>
<body>
<a href="page2.php?val=sample" value="fixed text">some text </a>
</body>
</html>
page2.php
<?php
$value=$_GET['val'];
?>
<html>
<head>
</html>
<body>
<?php
echo $value;
?>
</body>
</html>