0
I’m trying to make a form, created in the index.php file, that sends by method POST
for the.php sign-up page and with a header()
send a verification variable back to the index.
However, when it goes back 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>
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.
Your
header
shouldn’t beLocation: index.php?login=X
, whereX
is the respective value? In fact, it says that which file does not exist?– Woss