Skip to content

Instantly share code, notes, and snippets.

@andersonFaro9
Created November 6, 2014 16:37
Show Gist options
  • Save andersonFaro9/049088d9c038b6bec83c to your computer and use it in GitHub Desktop.
Save andersonFaro9/049088d9c038b6bec83c to your computer and use it in GitHub Desktop.
<?php
//Página index.php
require_once 'validacao-de-campos.php';
?>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/janela.css">
<script type="text/javascript" src="js/jquery-1.11.1.js">
</script>
<script type="text/javascript" src="js/validacao.js">
</script>
<script type="text/javascript" src="js/boostrap.js">
</script>
<script type="text/javascript" src="js/boostrap-min.js">
</script>
</head>
<body>
<div class="alert alert-success" role="alert"></div>
<form action="index.php" id="form" method="post">
<div class="form-group">
<?php $validaCampos = validaCampos(); ?>
<label for="exampleInputEmail1">Email</label>
<input name="email" type="email" class="form-control" id="email" placeholder="Digite seu email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Senha</label>
<input name="senha" type="password" class="form-control" id="senha" placeholder="Digite sua senha">
</div>
<button name="ok" type="submit" id="enviar" class="btn btn-default">Enviar</button>
</form>
//Página validacao-de-campos.php
<?php
function validaCampos()
{
$email = $_POST['email'];
$senha = $_POST['senha'];
$erros = 0;
if (empty ($email) or strstr($email, '@') == false) {
echo '<p>Campo email deve ser preenchido</p>';
$erros = 1;
}
if (empty($senha) or $senha < 5) {
echo '<p>Campo senha deve ser preenchido</p> .<br/>';
$erros = 1;
}
if ($erros == 0) {
header('Location:autentica.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment