K
K
Konstantin Khairov2016-02-20 00:12:52
PHP
Konstantin Khairov, 2016-02-20 00:12:52

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;
  
  
}

doesn't work and doesn't check if the script continues to execute
after trying to make the condition !$login , but it still goes on . But tried to do $login==true still goes further and adds the field , but tried to do $login>0 still goes further . I don't understand what's wrong, what's wrong. Help me please . Here is the whole code and the first three IFs do not work, as well as checking whether Mail is correct
<?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();

?>

I can't figure out what's wrong...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AntonMZ, 2016-02-20
@Kaylos

Can you please explain to me what does === mean?
Why is it concluded that if's do not work.

M
Max, 2016-02-20
@matios

A little offtopic
This is of course hard! Never, never, never do that!

setcookie("login", $login);
  setcookie("password", $pass_md);

And like this too:
Have you heard anything about SQL injection? Apparently not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question