Answer the question
In order to leave comments, you need to log in
The variable is not checked through If what to do?
Hello everyone, I am registering on the site. I want to check if all the fields are entered I wrote this code
if ($login===false){
header ("Location: http://test1.ru/register.php/string=false");
}else{
$login_error=0;
}
<?PHP
//------------------------------------
$login=$_POST["login"];
$mail=$_POST["mail"];
$pass=$_POST["pass"];
$pass_md= md5($pass);
//=======================
//Проверяем все ли поля введены
//=======================
if ($login===false){
header ("Location: http://test1.ru/register.php/string=false");
}else{
$login_error=0;
}
if ($pass===false){
header ("Location: http://test1.ru/register.php/string=false");
}else{
$pass_error=0;
}
if (!$mail){
header ("Location: http://test1.ru/register.php/string=false");
}else{
$mail_error=0;
}
// ======================
// Проверяем E-Mail
// ======================
preg_match_all ("/.*@.*\.[a-z]+/i",$mail,$mailarray);
$mail_check=$mailarray[0][0];
if ($mail_check==true){
$mail_error=0;
}else {
header ("Location: http://test1.ru/register.php?mail=false");
}
// ======================
// Проверяем Все ли верно , задаем coockie и добавляем данные в БД
// ======================
include ("dbconfig.php");
$check = $mysqli->query("INSERT INTO `users` (`id`,`login`,`password`,`mail`) VALUE ('','".$login."','".$pass_md."','".$mail."')");
if ($check===true){
setcookie("login", $login);
setcookie("password", $pass_md);
header ("Location: http://test1.ru/index.php?register=true");
}else {
header ("Location: http://test1.ru/register.php?login=false");
}
$mysqli->close();
?>
Answer the question
In order to leave comments, you need to log in
Can you please explain to me what does === mean?
Why is it concluded that if's do not work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question