0

Someone can tell me what's wrong with this codes? It doesn't appear the box with errors:

envia.php

<!--BEGIN box correcao-->   
<style type="text/css">
/* Box Style */

.success, .warning, .errormsgbox, .validation 
{
	border: 1px solid;
	margin: 0 auto;
	padding:10px 5px 10px 50px;
	background-repeat: no-repeat;
	background-position: 10px center;
    font-weight:bold;
    width:450px;
}

.success 
{
	color: #4F8A10;
	background-color: #DFF2BF;
	background-image:url('images/success.png');
}

.warning 
{
	color: #9F6000;
	background-color: #FEEFB3;
	background-image: url('images/warning.png');
}

.errormsgbox 
{
	color: #D8000C;
	background-color: #FFBABA;
	background-image: url('images/error.png');
}

.validation 
{
	color: #D63301;
	background-color: #FFCCBA;
	background-image: url('images/error.png');
}
</style>
<!--END box correcao-->

<?PHP
//ligar base de dados
include "db_connect.php";

/////////// ALUNO ///////////////
$username = $_POST ['username'];
$pass = $_POST ['pass'];
$conf_pass = $_POST ['conf_pass'];
$nome = $_POST ['nome'];
$data_nasc = $_POST ['data'];
$morada = $_POST ['morada'];
$cp1 = $_POST ['cp1'];
$cp2 = $_POST ['cp2'];
$cp_aluno = $cp1 .'-'. $cp2;
$telemovel = $_POST ['tele'];
$email = $_POST ['email'];

///////////ENC.EDU.///////////////
$nome_ee = $_POST ['nome_ee'];
$morada_ee = $_POST ['morada_ee'];
$cp1_ee = $_POST ['cp1_ee'];
$cp2_ee = $_POST ['cp2_ee'];
$cp_ee = $cp1_ee .'-'. $cp2_ee;
$tele_ee = $_POST ['tele_ee'];
$email_ee = $_POST ['email_ee'];

//BEGIN VALIDACAO
if (isset($_POST['submit'])) 
{
	//Declara um Array para armazenar a mensagem de erro
	$error = array();
    
	//se o nome for entregue
	if (empty($_POST['username'])) 
	{
        $error[] = "Preencha o campo 'Username'.";
    } 
}
//END VALIDACAO
?>

inscricao.php

<?PHP
     
include 'topo.php';

?>

<!-- content -->
     
    <div class="indent">
     
    <h2> Inscrição </h2>
     
     
    <form action="envia.php" method="post" class="registration_form" onsubmit="return validar()" >
    <fieldset>
    <legend> ALUNO </legend>
    
	<table> 
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Username*: </label>
			</td>
			
			<td>
				<input type="text" size="30" name = "username" value=
				<?php
				if (isset($_POST['username'])) echo $_POST['username']; 
				?>></div>
			</td>
		</tr>
    
	
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Password*: </label>
			</td>
			
			<td class="separador">
				<input type="password" size="25" name = "pass"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Confirma Password*: </label>
			</td>
			
			<td>
				<input type="password" size="25" name = "conf_pass"/></div>
			</td>
		</tr>
	
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Nome*: </label>
			</td>
			
			<td>
				<input type="text" size="40" name = "nome"/></div>
			</td>
		</tr>
    
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Data de Nascimento*: </label>
			</td>
			
			<td>
				<input type="text" name="data" maxlength="10" onkeyup="Formatadata(this,event)" onkeypress="return isNumberKey(event)"/> (DD/MM/AAAA) </div>
			</td>
		</tr>
    
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Morada: </label>
			</td>
			
			<td>
				<input type="text" onkeypress="return onlyNumbers();" size="39" name = "morada"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Código Postal: </label>
			</td>
			
			<td>
				<input id="txtChar" onkeypress="return isNumberKey(event)" type="text" size="5" maxlength="4" name = "cp1"/> - <input id="txtChar" onkeypress="return isNumberKey(event)" type="text" size="4" maxlength="3" name = "cp2"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Telemóvel*: </label>
			</td>
			
			<td>
				 <input id="txtChar" onkeypress="return isNumberKey(event)" type="text" size="10" maxlength="9" name = "tele"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>E-Mail*: </label>
			</td>
			
			<td>
				 <input type="text" value="" name = "email" size = "25"/></div>
			</td>
		</tr>
	</table>
    </fieldset>
    
	<br/>
    
	<fieldset>
    <legend> ENCARREGADO DE EDUCAÇÃO </legend>
     <table>
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Nome*: </label>
			</td>
			
			<td>
				<input type="text" size="40" name = "nome_ee"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>Morada: </label>
			</td>
			
			<td>
				<input type="text" size="39" name = "morada_ee"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				 <br/>
				<div class="field"><label>Código Postal: </label>
			</td>
			
			<td>
				<input id="txtChar" onkeypress="return isNumberKey(event)" type="text" size="5" maxlength="4" name = "cp1_ee"/> - <input id="txtChar" onkeypress="return isNumberKey(event)" type="text" size="4" maxlength="3" name = "cp2_ee"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field">Telemóvel*: </label>
			</td>
			
			<td>
				<input id="txtChar" onkeypress="return isNumberKey(event)" type="text" size="10" maxlength="9" name = "tele_ee"/></div>
			</td>
		</tr>
		
		<tr>
			<td align="right">
				<br/>
				<div class="field"><label>E-Mail*: </label>
			</td>
			
			<td>
				<input type="text" value="" name = "email_ee" size = "25"/></div>
			</td>
		</tr>
	</table>
    </fieldset>
    <br/>
    * Campos Obrigatórios
    <br/>
    <input name="submit" type="submit" value="Enviar">
    <input type="Reset" value="Apagar">
     
    </form>
     
    </div>
    </div>
     
     
    <?PHP
     
    include 'rodape.php';
     
    ?>

Thank you,
PF2G

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by pzuurveen
0

where do you output this variable?
You just declare it

$error[] = "Preencha o campo 'Username'.";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.