How to modify a link with an user ID

<a href="https://123.com/'.$_SESSION["usersId"].' " target="_blank"><img src="./images/w.jpg"></a>

Hello, I’m new to coding and I was wondering how can I make a custom link with an user ID directly taken from my database. The name usersId is a column in a mySQL table and I take that usersId from a session. Can you please help me fix the problem

I tried to use a $_SESSION to insert the user id in the link but it seem that it didn’t work and when I open a session on my website it just removes the $_SESSION and give me a link without the user id at the end.

>Solution :

Have you defined your session object?
It should look like this;

$_SESSION["userId"] = your_mysql_object["userId"]

Leave a Reply