A very simple PHP code used to dial phone

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>XXX联系方式</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <style>
        .table th { 
            text-align: center; 
            font-size: 18px;
            vertical-align: middle !important;
            }
        .table td {
            font-size: 16px;
            vertical-align: middle !important;            
        } 
        h2 { font-weight:bold;text-align: center;}
    </style>
</head>
<body>
<h2>XXX联系方式</h2> 
<table class="table table-bordered">   
    <thead>   
        <tr> 
            <th>序号</th>                
            <th>姓名</th>   
            <th>操作</th>   
        </tr>   
    </thead>   
    <tbody>   
        <?php
    
            $conn = mysqli_connect('127.0.0.1', 'root', 'root','table') or die( 'Connection failed:'. Mysqli_error ());
             // set the encoding, Chinese distortion preventing 
            the mysqli_query ( $ Conn , "SET UTF8 names" ); 
             $ SQL = "SELECT * from TB_NLianXiFS ID Order by ASC ' ; $ retval = the mysqli_query ( $ Conn , $ SQL ) or Die ( "Error in Query: $ SQL .". mysql_error ());
             the while ( $ Row = mysqli_fetch_assoc ( $ retval )) 
            { 
                echo '<TR>' ;
                echo '<td align="center">'.$row['id'].'</td>';
                echo '<td>'.$row['name'].'</td>';
                echo '<td><button type="button" class="btn btn-success" onclick="Calltel('.$row['tel'].');">&nbsp;拨号&nbsp;</button> </td>';
                echo "</tr>";
            }
            mysqli_free_result($retval);
            $ip = getIp();
            $rq = date("Y-m-d h:i:s"); 
            $InsertSQL = "Insert into tb_njlb(ip,riqi) values ('$ip','$rq')" ;
            $result = mysqli_query($conn,$InsertSQL)or die("Error in Query ".mysql_error()); 
            mysqli_close($conn);
        ?>        
    </tbody>   
</table> 
<script type="text/javascript">
    function Calltel(tel){
        window.location.href = "tel:"+tel;
    }
</script>
</body>
</html>
<?php
function getIp()
{
    if ($_SERVER["HTTP_CLIENT_IP"] && strcasecmp($_SERVER["HTTP_CLIENT_IP"], "unknown")) {
        $ip = $_SERVER["HTTP_CLIENT_IP"];
    } else {
        if ($_SERVER["HTTP_X_FORWARDED_FOR"] && strcasecmp($_SERVER["HTTP_X_FORWARDED_FOR"], "unknown")) {
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
        } else {
            if ($_SERVER["REMOTE_ADDR"] && strcasecmp($_SERVER["REMOTE_ADDR"], "unknown")) {
                $ip = $_SERVER["REMOTE_ADDR"];
            } else {
                if (isset ($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'],
                        "unknown")
                ) {
                    $ip = $_SERVER['REMOTE_ADDR'];
                } else {
                    $ip = "unknown";
                }
            }
        }
    }
    return ($ip);
}
?>

 

Guess you like

Origin www.cnblogs.com/xenli/p/12463452.html