2014-12-12 1 views
-1
require '../core/connect.php'; 

if(isset($_POST['register'])&&!empty($_POST['register'])) 
{ 
    $first = $db->real_escape_string(trim($_POST['fname'])); 
    $last = $db->real_escape_string(trim($_POST['lname'])); 
    $email = $db->real_escape_string(trim($_POST['email'])); 
    $pass = $db->real_escape_string(trim($_POST['password'])); 
    $repass = $db->real_escape_string(trim($_POST['repass'])); 

    if($first && $last && $email && $pass && $repass) 
    { 
     if($pass == $repass) 
     { 
      if (strstr($email, "@") && strstr($email, ".")) 
      { 

       $query = ("SELECT email FROM users WHERE email='$email'"); 
       $result = $db->query($query); 

       if ($result->num_rows == 0) 
       { 
        if(strlen($pass) > 8) 
        { 
         if(strlen($pass) < 18) 
         { 
          $pass = md5($pass); 

          $register = "INSERT INTO users (id,firstname,lastname,email,password,videos,created,admin) 
          VALUES ('', '$first', '$last', '$email', '$pass', '1', NOW()), '0'"; 

          if($db->query($register) === TRUE) 
          { 
           echo "Congrats, you have been registered."; 

          } 
          else 
           die('Sorry, there was a problem creating your account.'); 
         } 
         else 
          die('Your password must be no more then 18 characters.'); 
        } 
        else 
         die('Your password must be at least 8 characters.'); 
       } 
       else 
        die('Sorry, that email is already in use.'); 
      } 
      else 
       die('Your email is not correct.'); 
     } 
     else 
      die('Your passwords must match.'); 
    } 
    else 
     die('You must enter all the fields.'); 
} 

계속해서 죽어 가고 있습니다.PHP 등록 페이지 문제

if($db->query($register) === TRUE) 
          { 
           echo "Congrats, you have been registered."; 

          } 
          else 
           die('Sorry, there was a problem creating your account.'); 

그것은 내가 이중 다른 PHP 페이지로 점검 때문에 만들어 연결의 모든 작동, 난 그냥 issue.Any 도움말을 찾을 수 없습니다 및 팁 감사합니다, 연결 페이지가 아닌 대단히 고마워! 내가 확실 해요 의견에 명시된 바와 같이 :

+0

'NOW()', '<= 잘못 배치 된 괄호. ='NOW(), '0') "; '- 또한 MD5를 사용하지 마십시오. 부서진. 오류를 잡아내는 현재의'die()'방법은 여러분이 사용해야하는 것이 아닙니다. 대신 실제 오류를 가져 오십시오. http://php.net/manual/en/mysqli.error.php –

+0

** 경고 ** : 사용자 고유의 액세스 제어 계층을 작성하는 것은 쉽지 않으며 심각하게 잘못 처리 할 수있는 기회가 많습니다. 이 간단한 예에서 [적절한 탈출] (http://bobby-tables.com/php)이 무분별하게 제공되어 위험한 [SQL 주입 취약점] (http://bobby-tables.com/) . [Laravel] (http://laravel.com/)과 같은 최신 [개발 프레임 워크] (http://codegeekz.com/best-php-frameworks-for-developers/)가있을 때 자신의 인증 시스템을 작성하지 마십시오. 강력한 [인증 시스템] (http://laravel.com/docs/security)이 내장되어 있습니다. – tadman

+0

또한 PDO를 사용하는 경우 [prepared statements] (http://php.net/manual/en/pdo.prepared-statements.php)를 사용하여 데이터 바인딩 및 이스케이프 처리를 처리하십시오. 여기에서했던 것처럼 수동으로 이스케이프 함수를 호출 할 필요가 없습니다. 코드를 혼란스럽게 만들고 코드에서 탈출하는 것을 잊어 버리면 커다란 문제에 노출됩니다. 너의 만연한 또는'죽는'의 너의 만연한 사용은 또한 극히 혼란 스럽다. 표시된 오류가있는 양식을 다시 제출하지 않으시겠습니까? – tadman

답변

1

당신은 그것을 읽을 여부를 한 경우 :

이 줄 : 잃어 버렸던 브래킷이

VALUES ('', '$first', '$last', '$email', '$pass', '1', NOW()), '0'"; 
                  ^right there 

)

이는 NOW() 함수의 일부이며 '0' 다음에 이동해야합니다.

VALUES ('', '$first', '$last', '$email', '$pass', '1', NOW(), '0')"; 

플러스, 난 당신이 암호 저장을 위해 MD5를 사용났습니다. MD5는 오래되어 깨진 것으로 간주되어 더 이상 암호 저장을 신뢰할 수 없어야합니다.