Page 1 of 1

How do I create a unique link?

Posted: Mon Nov 06, 2017 3:36 pm
by IChaps
Hello.

I'm looking into creating a member's directory.
The results will show, the member's profile image, full name and either 1 or 2 unique hyperlinks.

ie.
Image Name Friend Request Contact
John Smith Request Get In touch
Joe Bloggs Request Get In touch

If I want to make a friend of John Smith, then I will click on Request next to John Smith. If I wanted to Contact John Smith then I click on Get In touch. And those links will only apply to John Smith only.

I don't know how to create a link unique to each person..

Can anyone please help?
Thank You.

Re: How do I create a unique link?

Posted: Tue Nov 07, 2017 2:08 am
by chorn
just add the target user-id to the link.

Re: How do I create a unique link?

Posted: Tue Nov 07, 2017 2:32 pm
by IChaps
Hello chorn,

Thank you for your reply.

I'm not sure what you mean.
Do you mean the primary key?

If so, I don't know how to do it, and how to proceed if the link is clicked.

Thanks.

Re: How do I create a unique link?

Posted: Wed Nov 08, 2017 3:46 am
by chorn
do it the same way you output the information

Code: Select all

<a href="request.php?member=<?=$user['id']?>">request</a>
or similar, depending on how you actually do it. then proceed with your business logic within the other file.

Re: How do I create a unique link?

Posted: Wed Nov 08, 2017 2:34 pm
by IChaps
Hello chorn,

Thank you very much.
I'll try it.

Kind Regards.

Re: How do I create a unique link?

Posted: Thu Nov 09, 2017 1:11 pm
by IChaps
Hello chorn.

My apologies,

I'm still not understanding.

I've tried to follow your example, but I'm sill unsure.
I have created the line:-

Code: Select all

<a href="/request.php?member_id=<?php echo $user['member_id']; ?>">Link</a>
In my database, for the primary key I've used member_id

Thanks.

Re: How do I create a unique link?

Posted: Fri Nov 10, 2017 12:30 am
by chorn
now in the request.php you can handle the functionality for the member that you get via $_GET['member_id'].

Re: How do I create a unique link?

Posted: Fri Nov 10, 2017 2:57 pm
by IChaps
Hi.

I've tried using

Code: Select all

<a href="/request.php?member_id=<?php echo $user['member_id']; ?>">Link</a>
However it don't work, and the page will not load.

As I'm using a php file, I've forgotten the php way to create a hyperlink.

Thanks.

Re: How do I create a unique link?

Posted: Sun Nov 12, 2017 11:55 pm
by chorn
first of all you should enable error reporting

Code: Select all

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Re: How do I create a unique link?

Posted: Tue Nov 14, 2017 3:49 pm
by IChaps
Hello chorn.

I'd just like to thank you very much for your time and help.
I have now managed to create the unique link I wanted with your help!

In my directory file I used the line:

Code: Select all

<a href="request.php?member_id=<?=$id?>">request friendship</a>
and in the request.php file, I've written:-

Code: Select all

$userid = $_GET['member_id'];
before accessing the database.

Thank you again! :)