How to get user name ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get user name ?

When we go to a website,we can see hi (my name)...how we do it for our website? Every visitors should see hi (their name)...

15th Sep 2020, 5:23 AM
Lasindu Migara
Lasindu Migara - avatar
4 Answers
+ 2
This is common for those site which hve login/sigin feature. They select user name from registeration page/user name and add a function to greet with hi user name according to username-password pair/user name -emailid pair from database . Say When kevinhart@gamail.com login greet "hi Kevin".
15th Sep 2020, 5:39 AM
Divya Mohan
Divya Mohan - avatar
+ 2
If you can access on which sololearn id your code is opening you can also do that. A rough idea Document. Onload =get the I'd and then find name and alert "hi name". Iff there is something feature like this here on sololearn
15th Sep 2020, 5:42 AM
Divya Mohan
Divya Mohan - avatar
+ 1
let name = prompt('Your name?') || '❤'; // if user writes name or ❤ alert('Hi '+name); // simple JS solution
15th Sep 2020, 5:26 AM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
Thanks,but i wanna show that message with his/her name every time when user log without a promt..do you have any ideas ?
15th Sep 2020, 9:20 AM
Lasindu Migara
Lasindu Migara - avatar