Send user name in SESSION with form

Asked

Viewed 42 times

0

I am sending a form as follows:

inserir a descrição da imagem aqui

After uploading the video, I would like the uploaded video table to include the name of the uploaded user as well.

I tried with post and get method as follows:

$monitor = $_GET["nomecomp"];

However, the Undefined Index.

Anyway, how can I pull php’s SESSION username, and send it to mysql through:

$sql_logar = "INSERT INTO video_monitor (titulo_video, disciplina, link_video, coment_video, arquivo, data, monitor)
      VALUES ('$nome_video', '$disciplina', '$link_video', '$coment_video', 'Nenhum arquivo', NOW(), '$monitor')";
  • User ID and name are recorded in a Session?

  • put the code snippet where it is saved

  • I have not recorded in a SESSION... the only thing I pull is this: <?php echo $_SESSION['name']; ? > which is to display the name of the user that entered..

1 answer

2


If the user data is written to variables in the Session, you can for example send the data to the code that runs the Insert in the table like this for example:

<form action="" method="post">

<!-- AQUI OS CAMPOS DO SEU FORMULÁRIO -->

<input id="id_usuario" name="venda['id_usuario']" type="hidden" class="form-control" value="<?php echo $_SESSION['id_usuario']; ?>">

<input id="nome_usuario" name="nome_usuario" type="hidden" class="form-control" value="<?php echo $_SESSION['nome_usuario']; ?>">

</form>

  • This error happens: Data Too long for column 'monitor' at Row 1

  • Set the field to LONGTEXT and this appeared: <br /> <b>Notice</b>: Undefined index: nomecomp in <b>C:xampphtdocs ccmonitor.php</b> on line <b>127</b><br />

  • It is not recognizing the mysql nameplate field in the form

  • I got it right away, thanks!

  • If you can give a positive assessment of the question, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.