Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

How to pass arguments by clicking on hyperlink and then catch those in target php file?

Hi

I have one php file which contain some hyperlinks. I want php-coding that when a hyperlink is clicked then the target file should know the location (directory name & path) and hyperlink name/heading from where the hyperlink was clicked.

Target file should store this value in a variable.

For example : goto  [ http://thegurbani.com/index.php/Static-Category/audio.html  ]

You will seesome hyperlinks like 1. audio , 2. tmp 3. media

Now the target file which is "index.php" in each directory should know that it is activated by clicking on "audio" or in other case "tmp" or "media" and it should store this info in a vaiable.

Plz note number of hyperlinks and their names are dynamic. So your code should change accordingly.
0
theredcode
Asked:
theredcode
  • 2
1 Solution
 
afzzCommented:
Try the below code to pass the variable.
//In your php file
//$target can be audio tmp media anything
echo "<a href="index.php?src=$target">$target</a>";
 
//In your index.php file
$src=$_REQUEST['src'];
//now your passed variable is available in $src

Open in new window

0
 
afzzCommented:

//In your php file
//$target can be audio tmp media anything
echo "<a href=\"index.php?src=$target\">$target</a>";
 
//In your index.php file
$src=$_REQUEST['src'];
//now your passed variable is available in $src

Open in new window

0
 
theredcodeAuthor Commented:
Thanks very much.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now