I am developing a system that allows the student to send messages to the teacher and vice versa, but I found myself with an error in which, simply nothing happens. What I wanted to happen was that the student could send the message to the teacher, and for that, the student would have to be logged in, and his data would be passed through the session for identification, but that does not happen! p>
PHP:
<?php
session_start();
$_SESSION['alunoRm'] = "$rm";
$_SESSION['alunoSenha'];
$_SESSION['alunoNome'];
$_SESSION['alunoEmail'];
$_SESSION['alunoTurma'] = "$turma";
print("<pre>"); print_r($_SESSION); print("</pre>");
include_once("conexao.php");
$msg = $_POST['msg'];
$rmprof = $_POST['rmprof'];
$pegaRM = mysqli_query($conn, "SELECT * FROM professor WHERE RM =
$rmprof'");
if(mysqli_num_rows($pegaRM) == 0){
echo "<script language='javascript' type='text/javascript'>alert('Este RM de
professor não existe');window.location.href='aluno_escrv.php'</script>";
}
else{
$sql = "insert into mensagem (RM, mnsg, RM_PROF, Turma_ID) VALUES ('$rm',
'$msg', '$rmprof', '$turma')";
$inserir = mysqli_query($conn,$sql);
echo $_SESSION['alunoRm'];
}
?>
Variable data comes from HTML
<?php
session_start();
$_SESSION["alunoRm"];
$_SESSION["alunoSenha"];
$_SESSION["alunoNome"];
if(!isset($_SESSION["alunoRm"]) || !isset($_SESSION["alunoSenha"])){
header("Location: login.html");
exit;
}else{
?>
<html>
<head>
<style type="text/css" media="screen">
body{
font: 400 12px/16px "Roboto", Helvetica, Arial, sans-serif
}
.button:hover{
background: #43A047;
-webkit-transition: background 0.3s ease-in-out;
-moz-transition: background 0.3s ease-in-out;
transition: background-color 0.3s ease-in-out;
}
</style>
<title>Aluno - Mensagem</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style_cad_prof.css">
</head>
<body link="#777" vlink="#777" alink="#777">
<div class="content">
<div class="container">
<form action="envaluno.php" method="post" enctype="multipart/form-data" name="cadastro" id="contact" >
<h3>Aluno - Mensagem</h3>
<h4><?php echo "<span class='ola'>"; echo "Escreva sua mensagem "; echo "</span>"; echo "<span class='nome'>"; echo $_SESSION["alunoNome"]; echo "</span>";?> - <a href="perfilaluno.php">Voltar</a></h4>
<fieldset>
<input placeholder="RM do professor" type="number" tabindex="1" name="rmprof" required autofocus>
</fieldset>
<textarea name="msg" placeholder="Insira a sua mensagem aqui"></textarea><br>
</fieldset>
<br><fieldset>
<button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Enviar</button>
</fieldset>
</form>
</div>
</div>
</bod>
<?php }?>
HTML: link