I'm trying to make a form, created in the index.php file, which sends by POST
method to the cadastro.php page and with a header()
I send a check variable back to the index .
However, when it returns to the index.php page, it says that the file was not found and gives Error 404
.
index.php :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Exercicio 1</title>
</head>
<body>
<?php
echo '<form action="cadastro.php" method="post">
Nome: <input type="text" name="nome" value="" /> <br />
Email: <input type="text" name="email" value="" /> <br />
Senha: <input type="password" name="senha" value="" /> <br />
<input type="submit" value="Enviar" />
</form>';
if(@$_GET['login'] == 1){
echo 'Informe nome novamente!';
}
?>
</body>
</html>
cadastro.php :
<?php
require 'connection.php';
require 'database.php';
$usuario = array(
'nome' => $_POST['nome'],
'email' => $_POST['email'],
'senha' => $_POST['senha'],
);
if(empty($_POST['nome']) || strlen($_POST['nome']) < 5){
header("Location:index.php login=1");
}
else if(!strstr($_POST['email'], '@') || strlen($_POST['email']) < 5){
header("Location:index.php login=2");
}
else if(empty($_POST['senha']) || strlen($_POST['senha']) < 5){
header("Location:index.php login=3");
}
else{
DBCreate('usuarios', $usuario);
header("Location:index.php login=4");
} ?>
I'm using XAMPP on Windows.