0

以下是验证页面的一部分。一般来说,它工作得很好。该站点的容量很小,因此不太关心速度优化。我的问题是某些用户没有验证有效数据。大多数用户没有任何问题。例如,客户输入的街道地址为“2881 Hayden Creek Terrace”,但验证不会清除它。我对此很陌生,所以这些类型的东西可能很常见,但我猜问题出在客户浏览器中的字符集上。这可能是我应该研究的吗?有没有人看到代码有任何重大问题?

function validation_payment($_check='') {

    $_error = '' ;

    foreach( $_POST as $key => $value ) {

    $value = preg_replace( "/[^\w@&#,\-\.\s\!\?]/",'',$value ) ;
    $value = preg_replace( "/\s\s+/"," ",$value ) ;
    //echo $value.'</br>' ;
    $_POST[$key] = $value ;

    switch ($key) {

        case 'ADDRESS_STREET_LINE1':
            $value = preg_replace("/[^\w,\-\.\s]/","",$value) ;
            if( empty($value) ) {
                $_error = "Error: Please make sure the Street Address entered on LINE 1 is not blank.<br/>" ;
            }elseif( !preg_match("/\s/",$value) ) {
                $_error .= "Error: The Street Address on LINE 1 does not appear to contain a street location and street name. Please review it for accuracy.<br/>" ;
            }elseif( !( strlen($value) < 100 ) ) {
                $_error .= 'Error: The Street Address entered on LINE 1 contains too many characters.<br/>' ;
            }else{
                $_SESSION['BILLING'][$key] = $value ;
            }
            break ;

}
4

0 回答 0