2016-08-27 7 views
-2

電話の検証にtwilioスクリプトを使用します。私はあまりにも私の電話番号を、それを送信するが、私は常にこのメッセージを取得した後、私は常に、SMS経由でコードを取得する:Twilio sms verification:あなたの認証コードが間違っています

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コード:ここ

<?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'); 
?> 

db_functions.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

一般に、コードはひどいです。しかし、それはあなたの問題を説明するのは簡単です:

PHPのお知らせ:未定義のインデックス:ライン上のreserved.phpのコード4

  • $ _GETはコードが含まれていません。まずisset()でチェックしてください。

PHPのお知らせ:未定義の変数:行にreserved.php内の数字は15

  • 時々コードが空の文字列と変数「$数字」であるが、この中で定義されていないようです場合。書く前に$ numbers = [];

PHPのお知らせ:未定義の変数:この場合はまったく同じであるため、header.phpの中jsOnReadyライン上の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含まれているのは1つの項目「コード」。 isset()も同様に使うべきです。
+0

変更されたコードを送ってもらえますか?私は初心者です。 – kolag32

関連する問題