I have a step-by-step
sign-up system that would be step by step, ie the user first informs some data after others and others ... I want to go validating this data with PHP
(since I have to query the database to see if the user already exists). I have the following code:
<form method="post" action="forms/register.php">
<div class="modal-content modal-person modal-person2">
<div class="modal-header">
<h4 class="modal-title md-title">Registrar</h4>
<h5 class="modal-title md-title">login</h5>
</div>
<div class="modal-body">
<?php
if (isset($_REQUEST['error'])) {
$erro = $_REQUEST['error'];
if ($erro == "userexist") {
echo "<b class=\"text-danger\">Usuário ou email já cadastrado!</b>";
echo "<p class=\"text-danger\">Veja-os novamente..<br><br>";
} else if ($erro == "passdistint") {
echo "<b class=\"text-danger\">Senhas são distintas!</b>";
echo "<p class=\"text-danger\">Os campos de senha devem ter a mesma senha..<br><br>";
} else if ($erro == "every") {
echo "<b class=\"text-danger\">Erro desconhecido!</b>";
echo "<p class=\"text-danger\">Tente novamente mais tarde...<br><br>";
} else if ($erro == "sucess") {
echo "<script>
$(function(){
if($('.ativo').next().size())
{
$('.ativo')
.hide(800)
.removeClass('ativo')
.next()
.show(800)
.addClass('ativo');
}
});</script>";
}
}
?>
<div class="input-group md-input">
<span class="input-group-addon pq-txt" id="basic-addon1">웃</span>
<input type="text" class="form-control" maxlength="15" id="user" name="user" required="" placeholder="Usuário">
</div>
<div class="input-group md-input">
<span class="input-group-addon pq-txt" id="basic-addon1">@</span>
<input type="email" class="form-control" name="email" required="" placeholder="Email">
</div>
<div class="input-group md-input">
<span class="input-group-addon md-txt" id="basic-addon1">#*</span>
<input type="password" class="form-control" maxlength="15" id="senha" required="" name="pass1" placeholder="Senha">
<span class="input-group-addon md-txt confirm" id="basic-addon1"><span class="confirm" >#*</span></span>
<input type="password" class="form-control confirm" maxlength="15" id="senha2" required="" name="pass2" placeholder="Confirmar Senha">
</div>
<input type="hidden" name="step" value="1">
<div class="barprogress" >
<div></div>
</div><br>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-success md-btn" value="Próximo"/>
<div class="progress">
<div class="progress-bar progress-bar-info" style="width: 33.3%">
</div>
</div>
</div>
</div>
<div class="modal-content modal-person modal-person2">
<div class="modal-header">
<h4 class="modal-title md-title">Registrar</h4>
<h5 class="modal-title md-title">perfil</h5>
</div>
<?php
if (isset($_REQUEST['error'])) {
$erro = $_REQUEST['error'];
if ($erro == "userexist") {
echo "<b class=\"text-danger\">Usuário ou email já cadastrado!</b>";
echo "<p class=\"text-danger\">Veja-os novamente..<br><br>";
} else if ($erro == "passdistint") {
echo "<b class=\"text-danger\">Senhas são distintas!</b>";
echo "<p class=\"text-danger\">Os campos de senha devem ter a mesma senha..<br><br>";
} else if ($erro == "every") {
echo "<b class=\"text-danger\">Erro desconhecido!</b>";
echo "<p class=\"text-danger\">Tente novamente mais tarde...<br><br>";
} else if ($erro == "sucess2") {
echo "<script>
$(function(){
if($('.ativo').next().size())
{
$('.ativo')
.hide(800)
.removeClass('ativo')
.next()
.show(800)
.addClass('ativo');
}
});</script>";
}
}
?>
<div class="modal-body">
<center><img src="..." alt="..." width="100" height="100" class="img-circle perfil"></center><br>
<div class="input-group pq-input">
<span class="input-group-addon pq-txt" id="basic-addon1">웃</span>
<input type="file" class="form-control btn btn-default md-btn fileimg" accept="image/*" name="img" required="" >
</div>
<div class="input-group md-input">
<span class="input-group-addon md-txt" id="basic-addon1">Nome</span>
<input type="text" class="form-control" maxlength="200" required="" name="nome" placeholder="Nome Completo">
</div>
<div class="input-group md-input">
<span class="input-group-addon md-txt" id="basic-addon1">Nascimento</span>
<input type="date" class="form-control" required="" name="data">
<span class="input-group-addon md-txt" id="basic-addon1">Profissão</span>
<input type="text" class="form-control" maxlength="100" required="" name="profissao" placeholder="Trabalho em..">
</div>
<input type="hidden" name="step" value="2">
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-success md-btn" value="Próximo"/>
<div class="progress">
<div class="progress-bar progress-bar-info" style="width: 66.6%">
</div>
</div>
</div>
</div>
</form>
The first part (where the user informs login, email and password) is confirmed like this:
$mnpdo = new MinPDO();
$step = $_REQUEST['step'];
if($step == 1) {
if(isset($_REQUEST['user']) and isset($_REQUEST['email'])) {
$user = $_REQUEST['user'];
$email = $_REQUEST['email'];
try {
$result = $mnpdo->consult("users", "*", "email = '$email' or username = '$user'");
if($result[0]["username"] == $user or $result[0]["email"] == $email) {
header("location:../singup.php?error=userexist");
exit();
}
} catch (MinPDOException $ex) {
if($ex->getMessage() != "No results!") {
header("location:../singup.php?error=".$ex->getMessage());
exit();
}
}
if(isset($_REQUEST['pass1'])) {
$pass1 = $_REQUEST['pass1'];
if(isset($_REQUEST['pass2'])) {
$pass2 = $_REQUEST['pass2'];
if($pass1 != $pass2) {
header("location:../singup.php?error=passdistint");
exit();
} else {
header("location:../singup.php?error=sucess");
exit();
}
} else {
header("location:../singup.php?error=pass2");
exit();
}
} else {
header("location:../singup.php?error=pass");
exit();
}
} else {
header("location:../singup.php?error=user");
exit();
}
}
When it validates return sucess
and so I do the action to go to the next step ..
How do I when it comes back with sucess
or even failed it does not lose the data that has been validated?
I was wondering as long as it is validating to store the values in a $validado['meuinput']
array and when I return with the head I get the array values, but how do I pass the array to the page? (without being by url - get)