2 /* Envio de Mensagens ao Usuário (submeter_p.php)
3 1. Recebe o texto que formará a mensagem a ser encaminhada ao Administrador
4 2. Possui link para redirecionar os dados para a página 'envia_mensagem.php'
6 header ("Pragma: no-cache"); // sempre carregar página (não vai ser armazenada no cache http 1,0
7 header("Cache-Control: no-cache, must-revalidate"); // idem http 1,1
9 require_once("Globals.php");
10 // realiza conexão com o banco de dados
13 if( isset($_GET['id_to']) && ($_GET['id_to']) )
14 $id_to = $_GET['id_to'];
20 <title
>Enviar Mensagem
- Logador PET
</title
>
21 <link rel
="stylesheet" type
="text/css" href
="estilo.css">
22 <script language
="JavaScript" type
="text/javascript">
24 Função para testar se todos os campos foram preenchidos
27 function checkrequired(which
)
32 for (i
=0;i
<which
.length
;i++
)
34 var tempobj
=which
.elements
[i
];
35 if (((tempobj
.type
=="texto"||tempobj
.type
=="textarea"||tempobj
.type
=="select-one")&&tempobj
.value
==''))
46 alert("Você não preencheu todos os campos!")
52 function limita_tamanho(which
,limite
)
56 tamanho
= which
.value
.length
;
59 which
.value
= which
.value
.substring(0,limite
);
61 document
.getElementByID("contador").innerHTML
= "Member";
64 function updateCount(textareaId
, spanId
, limite
)
67 textarea
= document
.getElementById(textareaId
);
68 tamanho
= textarea
.value
.length
;
71 textarea
.value
= textarea
.value
.substring(0,limite
);
77 if (textarea
.value
.length
> limite
)
79 textarea
.value
= textarea
.value
.substring(0, limite
);
81 document
.getElementById(spanId
).innerHTML
= limite
- textarea
.value
.length
;
89 echo "<center><h2>Enviar Mensagem</h2></center>";
92 <form action
="envia_mensagem.php" method
="POST" name
="form1" onsubmit
="return checkrequired(this)">
93 <table border
="2" class='bordasimples' align
="center">
102 // obtém os dados de todos os usuários
103 $usuario_nome = mysql_query("SELECT usuario.id_user AS id, usuario.login AS nome FROM usuario ORDER BY nome");
106 // pesquisa usuário um a um e define a opção para selecionar seu nome para indicar quem está solicitando pendentes
107 while ($usuario = mysql_fetch_array($usuario_nome))
110 $id = $usuario['id'];
111 $nome = $usuario['nome'];
112 $usuarios[] = array("id"=>$id, "nome"=>$nome);
116 <tr
class='tbrow noHover'>
119 <SELECT id
="user_id_from" name
="user_id_from" style
="width:340px">
120 <OPTION checked value
=""></OPTION
>
122 foreach($usuarios as $usuario)
123 echo "<option value=\"". $usuario['id'] ."\">". $usuario['nome'];
133 <tr
class='tbrow noHover'>
134 <td
>Destinatário
:</td
>
136 <SELECT id
="user_id_to" name
="user_id_to" style
="width:340px">
137 <OPTION checked value
="0">Administrador
</OPTION
>
138 <optgroup label
="Usuários">
140 foreach($usuarios as $usuario)
141 echo "<option value=\"". $usuario['id'] ."\">". $usuario['nome'];
151 echo "<input type='hidden' name='user_id_to' value='". $id_to ."'>";
156 <tr
class='tbrow noHover'>
159 <table style
="border:0">
161 <td
><textarea id
="texto" cols
="40" rows
="10" name
="texto" onKeyUp
="updateCount('texto', 'contador', 1024)"></textarea
></td
>
164 <td
>Restam
<i
><span id
="contador">1024</span
></i
> caracteres
.</td
>
170 <tr
class='tbrow noHover' align
="center">
174 echo "<input type='hidden' name='quick_send' value='0'>";
176 echo "<input type='hidden' name='quick_send' value='1'>";
178 <input type
="submit" value
="Enviar"> 
; 
;<input type
="reset" value
="Limpar Dados">
184 <center
><a href
="index.php"><< Voltar p
/ Logador
</a
></center
>