Hello all,
I've made a relatively simple form that submits the values of several text boxes into a new table on my database.
One of those is a 'name' field. However I don't want the user to be able to write their own name, but rather get the users user name and insert that value instead.
I tried just changing the variable to the constant "{USER_NAME}" but it didn't like that at all.
I'm sure this is not that complicated... or is it?
Thanks
Tim
USER_NAME is constant and so it's global if you included init.inc.php to your page , maybe you are put it wrong way
post your code if you need more support
Thanks Sami
Well ok, here is the php that passes the variables onto the database.
$user_name = get_username($uid);
$sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$user_name', '$email', '$datetime')";
include/init.inc.php is defined at the start.
Its actually returning "anonymous" now so i think i'm on the right track...
try this
$user_name = get_username(USER_ID);
Or this
$user_name = USER_NAME;
Sami
You are a genius. Thanks for taking the time to think about that ;)
You've made one Australian teenager very happy :)
Both options work seamlessly.
Thank-you
Tim
You are welcome ,
Actually using 2nd method would save more resource than first one and it's recommended
To get any other user's name than current user you can use get_username function