Skip to main content
Participant
September 4, 2009
Answered

automatically send MM_Username as author in Form

  • September 4, 2009
  • 2 replies
  • 600 views

Hello,

on my website im trying to add something like a forum or a guestbook. All members got a name and i can print it as in the FAQ described with $_SESSION['MM_Username'] and filtering the name in the recordset. But now I have a form, and want to submit the username of the current user to the database table, so i can show the name in the post. How is it possible to send the MM_Username to the database, so it will be saved as the current users name? I've tried a little, but can't find any solution!

Thank you and kind regards!

This topic has been closed for replies.
Correct answer David_Powers

Noemis wrote:


But now I have a form, and want to submit the username of the current user to the database table, so i can show the name in the post. How is it possible to send the MM_Username to the database, so it will be saved as the current users name?

If the page begins with session_start(), you can put the value of $_SESSION['MM_Username'] in a hidden form field.

<input type="hidden" name="username" id="username"

value="<?php echo $_SESSION['MM_Username']; ?>" />

When the form is submitted, the username will be in the $_POST array as $_POST['username'].

2 replies

David_Powers
David_PowersCorrect answer
Inspiring
September 5, 2009

Noemis wrote:


But now I have a form, and want to submit the username of the current user to the database table, so i can show the name in the post. How is it possible to send the MM_Username to the database, so it will be saved as the current users name?

If the page begins with session_start(), you can put the value of $_SESSION['MM_Username'] in a hidden form field.

<input type="hidden" name="username" id="username"

value="<?php echo $_SESSION['MM_Username']; ?>" />

When the form is submitted, the username will be in the $_POST array as $_POST['username'].

Nadia-P
Inspiring
September 5, 2009

DW Application Dev forum

May be the best place to ask this question.