How do I create a unique link?

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
IChaps
New php-forum User
New php-forum User
Posts: 123
Joined: Tue Mar 01, 2016 3:07 pm

Mon Nov 06, 2017 3:36 pm

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.

chorn
php-forum Fan User
php-forum Fan User
Posts: 563
Joined: Fri Apr 01, 2016 2:18 am

Tue Nov 07, 2017 2:08 am

just add the target user-id to the link.

IChaps
New php-forum User
New php-forum User
Posts: 123
Joined: Tue Mar 01, 2016 3:07 pm

Tue Nov 07, 2017 2:32 pm

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.

chorn
php-forum Fan User
php-forum Fan User
Posts: 563
Joined: Fri Apr 01, 2016 2:18 am

Wed Nov 08, 2017 3:46 am

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.

IChaps
New php-forum User
New php-forum User
Posts: 123
Joined: Tue Mar 01, 2016 3:07 pm

Wed Nov 08, 2017 2:34 pm

Hello chorn,

Thank you very much.
I'll try it.

Kind Regards.

IChaps
New php-forum User
New php-forum User
Posts: 123
Joined: Tue Mar 01, 2016 3:07 pm

Thu Nov 09, 2017 1:11 pm

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.

chorn
php-forum Fan User
php-forum Fan User
Posts: 563
Joined: Fri Apr 01, 2016 2:18 am

Fri Nov 10, 2017 12:30 am

now in the request.php you can handle the functionality for the member that you get via $_GET['member_id'].

IChaps
New php-forum User
New php-forum User
Posts: 123
Joined: Tue Mar 01, 2016 3:07 pm

Fri Nov 10, 2017 2:57 pm

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.

chorn
php-forum Fan User
php-forum Fan User
Posts: 563
Joined: Fri Apr 01, 2016 2:18 am

Sun Nov 12, 2017 11:55 pm

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);

IChaps
New php-forum User
New php-forum User
Posts: 123
Joined: Tue Mar 01, 2016 3:07 pm

Tue Nov 14, 2017 3:49 pm

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! :)

Post Reply