2016-08-27 9 views
-2

전화 확인을 위해 twilio 스크립트를 사용합니다. 내가 너무 내 전화 번호를 보내하지만 난 항상이 메시지가 후 나는 항상 SMS를 통해 코드를 얻을 :Twilio SMS 확인 : 인증 코드가 잘못되었습니다

PHP Notice: Undefined index: code in reserved.php on line 4 
PHP Notice: Undefined variable: numbers in reserved.php on line 15 
PHP Notice: Undefined index: id in /db_functions.php on line 53 
PHP Notice: Undefined index: phone in /db_functions.php on line 54 
PHP Notice: Undefined index: verified in /db_functions.php on line 56 
PHP Notice: Undefined index: start in /db_functions.php on line 57 
PHP Notice: Undefined index: nb_display in /db_functions.php on line 58 
PHP Notice: Undefined variable: jsOnReady in header.php on line 19 

I : 내 오류 로그에 다음과 같은 오류를 얻을 수

"인증 코드가 잘못" 내 데이터베이스에 다 가지고 ..?

여기 내 reserved.php 코드 : 여기에 db_functions.php 코드

<?php 
include_once('.../webzone.php'); 

$code = $_GET['code']; 

if($code=='') $jsOnReady = "$('#code').focus();"; 
else $numbers = get_sms_numbers(array('code'=>$code)); 

include_once('.../..../header.php'); 
?> 

<div class="container"><center> 

<?php 
if(count($numbers)>0) { 

    if($numbers[0]['verified']!=1) { 
     $m1 = new MySqlTable(); 
     $sql = 'UPDATE '.$GLOBALS['db_table']['sms'].' SET verified=1 WHERE code="'.$m1->escape($code).'"'; 
     $m1->executeQuery($sql); 
    } 

    include_once('locked_content.php'); 

} 
else { 
    ?> 
    <h3>Your verification code</h3> 
    <p class="alt" style="margin-bottom:20px;">Please enter the code you have received by SMS</p> 
    <form method="GET"> 
    <input type="text" id="code" name="code" placeholder="Your verification code" style="padding:10px; width:300px;" value="<?php echo $code; ?>"><br> 
    <input type="submit" class="btn btn-primary btn-large" value="Verify my code"> 
    </form> 
    <?php 
    if($code!='' && count($numbers)==0) { 
     $message = 'Your verification code is incorrect'; 
     echo '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">x</button>'.$message.'</div>'; 
    } 
} 

?> 

</center> 
</div> 

<?php 
include_once('.../.../footer.php'); 
?> 

: 도움을

<?php 

function add_history($criteria=array()) { 
    $type = $criteria['type']; 
    $phone = $criteria['phone']; 
    $message_id = $criteria['message_id']; 
    $message = $criteria['message']; 
    $results = $criteria['results']; 

    $m1 = new MySqlTable(); 
    $sql = 'INSERT INTO '.$GLOBALS['db_table']['sms_history'].' (type, phone, message_id, message, results, created) VALUES ("'.$m1->escape($type).'", "'.$m1->escape($phone).'", "'.$m1->escape($message_id).'", "'.$m1->escape($message).'", "'.$m1->escape($results).'", "'.date('Y-m-d H:i:s').'")'; 
    $m1->executeQuery($sql); 
} 

function add_sms_number($criteria=array()) { 
    $phone = $criteria['phone']; 
    $code = $criteria['code']; 

    $m1 = new MySqlTable(); 
    $sql = 'INSERT INTO '.$GLOBALS['db_table']['sms'].' (phone, code, created) VALUES ("'.$m1->escape($phone).'", "'.$m1->escape($code).'", "'.date('Y-m-d H:i:s').'")'; 
    $m1->executeQuery($sql); 
} 

function get_sms_history($criteria=array()) { 
    $type = $criteria['type']; 
    $phone = $criteria['phone']; 
    $start = $criteria['start']; 
    $nb_display = $criteria['nb_display']; 

    $m1 = new MySqlTable(); 
    $sql = "SELECT * FROM ".$GLOBALS['db_table']['sms_history']." WHERE 1 "; 

    if($type!='') $sql .= " AND type='".$m1->escape($type)."'"; 
    if($phone!='') $sql .= " AND phone='".$m1->escape($phone)."'"; 

    $sql .= " ORDER BY id DESC"; 

    if($nb_display!='') $sql .= ' LIMIT '.$start.', '.$nb_display; 

    $result = $m1->customQuery($sql); 

    if($GLOBALS['demo_mode']==1) { 
     for($i=0; $i<count($result); $i++) { 
      $result[$i]['phone'] = substr($result[$i]['phone'], 0, -4).'xxxx'; 
      if($result[$i]['phone']=='') $result[$i]['phone']='xxxx'; 
     } 
    } 

    return $result; 
} 

function get_sms_numbers($criteria=array()) { 
    $id = $criteria['id']; 
    $phone = $criteria['phone']; 
    $code = $criteria['code']; 
    $verified = $criteria['verified']; 
    $start = $criteria['start']; 
    $nb_display = $criteria['nb_display']; 

    $m1 = new MySqlTable(); 
    $sql = "SELECT * FROM ".$GLOBALS['db_table']['sms']." WHERE 1 "; 

    if($id!='') $sql .= " AND id='".$m1->escape($id)."'"; 
    if($phone!='') $sql .= " AND phone='".$m1->escape($phone)."'"; 
    if($code!='') $sql .= " AND code='".$m1->escape($code)."'"; 
    if($verified!='') $sql .= " AND verified='".$m1->escape($verified)."'"; 

    $sql .= " ORDER BY id DESC"; 

    if($nb_display!='') $sql .= ' LIMIT '.$start.', '.$nb_display; 

    $result = $m1->customQuery($sql); 

    if($GLOBALS['demo_mode']==1) { 
     for($i=0; $i<count($result); $i++) { 
      $result[$i]['phone'] = substr($result[$i]['phone'], 0, -4).'xxxx'; 
      if($result[$i]['phone']=='') $result[$i]['phone']='xxxx'; 
     } 
    } 

    return $result; 
} 

/* 
START Default add/update functions 
*/ 

function save_posted_data($data, $table_name) { 

    $s1 = new MySqlTable(); 

    $fields=''; 
    $fields_values=''; 
    if(count($data)>0) { 
     foreach($data as $ind => $value) { 
      $fields .= $s1->escape($ind).','; 
      $fields_values .= "'".$s1->escape($value)."',"; 
     } 
    } 

    $fields = substr($fields,0,-1); 
    $fields_values = substr($fields_values,0,-1); 

    $sql = "INSERT INTO $table_name ($fields) VALUES ($fields_values)"; 
    $s1->executeQuery($sql); 
} 

function update_posted_data($data, $id, $table_name) { 

    $s1 = new MySqlTable(); 

    $fields=''; 
    if(count($data)>0) { 
     foreach($data as $ind => $value) { 
      $fields .= $s1->escape($ind)."='".$s1->escape($value)."',"; 
     } 
    } 

    $fields = substr($fields,0,-1); 
    $fields_values = substr($fields_values,0,-1); 

    $sql = "UPDATE $table_name SET $fields WHERE id='".$s1->escape($id)."'"; 
    $s1->executeQuery($sql); 
} 

?> 

감사합니다!

+0

[PHP : "주의 : 정의되지 않은 변수"와 "주의 : 정의되지 않은 인덱스"]의 사용 가능한 복제 (http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice- undefined-index) –

답변

0

일반적으로 코드는 끔찍합니다. 라인 4

  • $ _GET 코드가 포함되어 있지 않습니다에 reserved.php 코드 :

    PHP 공지 : 정의되지 않은 인덱스 그러나, 그것은 당신의 문제를 설명하기 쉽습니다. 먼저 isset()을 사용하여 확인해야합니다.

PHP 공지 : 정의되지 않은 변수를 줄 reserved.php의 숫자는 15

  • 이 정의되어 있지 않습니다 때로는 코드가 빈 문자열과 변수 '$ 숫자'것 같다 케이스. 쓰기 전에 $ numbers = [];

PHP 공지 : 정의되지 않은 변수 :이 경우는 동일하기 때문에 jsOnReady header.php 라인 (19)

  • 에 이전 코멘트를 참조하십시오.

PHP 공지 : 정의되지 않은 인덱스 : 라인 53 PHP 공지 사항에 /db_functions.php에서 ID : 정의되지 않은 인덱스 : 라인 (54) PHP 공지 사항에 /db_functions.php에 전화 : 정의되지 않은 인덱스 : 검증/db_functions 라인 .PHP (56) PHP 공지 사항 : 정의되지 않은 인덱스 : 라인 57 PHP 공지 사항에 /db_functions.php에 시작 ​​: 정의되지 않은 인덱스 : 당신은 배열 get_sms_numbers 전화 (58)

  • 라인에 /db_functions.php에서 nb_display 오직 한 항목 '코드'. isset()도 사용해야합니다.
+0

변경된 코드를 보내 주시겠습니까? 나는 초보자이다. – kolag32