Jump to content

Erro de flag


Recommended Posts

Boa noite;

tenho aqui um codigo para o painel de administração do meu site, onde o administrador ve os utilizadores inscritos no site, mas esta-me a dar os seguintes erros:

Notice: Undefined index: flag in C:\xampp\htdocs\LAYOUT\cpanel\utilizadores.php on line 83

Notice: Undefined index: flag in C:\xampp\htdocs\LAYOUT\cpanel\utilizadores.php on line 88

O codigo é o seguinte:


function checkButton(reg){

var chcks = document.getElementsByName("alunos[]");
for(var i=0; i  < chcks.length; i++){
	if (reg.checked==true){


function actDesact(op){

var checks = document.getElementsByName('alunos[]');

for(var i=0; i < checks.length; i++){
	if (op==1){
	}else if(op==0){



$sqlALunos = mysql_query("SELECT * FROM aluno ORDER BY idAluno ASC");
$numLinhas = mysql_num_rows($sqlALunos);
echo "<form name=f1 method=post action='utilizadores.php?flag=2'>";
//echo 'Adicionar Alunos<span style="margin-left:5px;"><a href=validaDados.php><img src="imgs/novo.png" border="0" title="Clique para adicionar novo aluno"></a>';
echo '<table width="1100" border=1>';
echo '<tr>';
echo '<th>ID</th>';
echo '<th>Nome</th>';
echo '<th>Morada</th>';
echo '<th>Localidade</th>';
echo '<th>Codigo Postal</th>';
echo '<th>Data de Nascimento</th>';
echo '<th>Telefone</th>';
echo '<th>Telemovel</th>';
echo '<th>Sexo</th>';
echo '<th>Login</th>';
echo '<th>Password</th>';
echo '<th>Email</th>';
echo '<th><input type="checkbox" name="alunosCheck" value=T title=Selecciona onclick="checkButton(this);"></th>';
echo '<th><img src="imgs/edita.png" border="0" width="12" title="Editar alunos"></th>';
echo '<th><img src="imgs/elimina.png" border="0"  width="12" title="Eliminar alunos"></th>';
echo '</tr>';

while($regAlunos = mysql_fetch_row($sqlALunos)){
echo '<tr>';
	echo '<td>'.$regAlunos[0].'</td>';
	echo '<td>'.$regAlunos[1].'</td>';
	echo '<td>'.$regAlunos[2].'</td>';
	echo '<td>'.$regAlunos[3].'</td>';
	echo '<td>'.$regAlunos[4].'</td>';
	echo '<td>'.$regAlunos[5].'</td>';
	echo '<td>'.$regAlunos[6].'</td>';
	echo '<td>'.$regAlunos[11].'</td>';
	echo '<td>'.$regAlunos[10].'</td>';
	echo '<td>'.$regAlunos[7].'</td>';
	echo '<td>'.$regAlunos[8].'</td>';
	echo '<td>'.$regAlunos[9].'</td>';
	//echo '<td align="center"><input type="checkbox" name="alunos[]" value='.$regAlunos[0].' title='.$regAlunos[1].'></td>';
	//echo '<td align="center"><a href="editarAluno.php?ID='.$regAlunos[0].'"><img src="imgs/edita.png" border="0" width="12" title="'.$regAlunos[0].'"></a></td>';
	echo '<td align="center"><a onClick="return confirm(\'Tem a certeza que deseja eliminar o registo referente ao aluno: '.$regAlunos[1].' ?\')" href="utilizadores.php?flag=1&idAluno='.$regAlunos[0].'"><img src="imgs/elimina.png" border="0"  width="12" title="Eliminar alunos"></a></td>';
echo '</tr>';

if ($_GET['flag']==1){
//'DROP TABLE alunos' --> eliminava a tabela alunos
// TRUNCATE TABLE alunos --> 
$sql_elimina = mysql_query("DELETE FROM aluno WHERE idAluno='$_GET[idAluno]' ");
}else if ($_GET['flag']==2){

if (!empty($_POST['alunos'])){
	while(list($key, $value) = each($_POST['alunos'])){
		$alunos[$key] = $value;	
	//echo sizeof($conhecimento);
	//$elementos = array('Amigos','Google','E-mail','Pub');
	for($i=0; $i<sizeof($alunos); $i++){
		echo '<br>Indice '.$i.' --> '.$alunos[$i];



Alguem me pode ajudar ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.