Jump to content

[SOLVED] How to determine which link was clicked?


coder9

Recommended Posts

hello brothers

 

let say i have two links

 

Link1 and Link2

 

that is on the same page.

 

How does PHP determine which link was clicked.

 

any sample script?

 

I know this is very simple i'm just only lost right now.

 

thanks.

Link to comment
Share on other sites

<?php
if( $_GET['link']=='1' ){
    echo "You Selected Link 1!";
}

if( $_GET['link']=='2' ){
    echo "You Selected Link 2!";
}
?>

<a href="page.php?link=1">Link 1</a>
<a href="page.php?link=2">Link 2</a>

 

assuming you name the php file page.php

Link to comment
Share on other sites

<?php
if( $_GET['link']=='1' ){
    echo "You Selected Link 1!";
}

if( $_GET['link']=='2' ){
    echo "You Selected Link 2!";
}
?>

<a href="page.php?link=1">Link 1</a>
<a href="page.php?link=2">Link 2</a>

 

assuming you name the php file page.php

 

 

Thanks man you are very helpful.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.