致命错误:未被捕获的错误:调用未定义的函数base_url()

时间:2019-06-19 17:53:04

标签: php mysql

我正在尝试将其设置为第一时间,但是会出现以下错误。

致命错误:未捕获错误:调用/home/u6256344/public_html/skripsiindah.online/login.php:51中未定义的函数base_url():堆栈跟踪:#0 {main}抛出于/ home / u6256344 / public_html /第51行上的skripsiindah.online/login.php

if (isset($_POST['login'])) {
    $username = anti_injection($_POST['username']);
    $password = anti_injection(md5($_POST['password']));

    // menghindari sql injection
    $injeksi_username = mysqli_real_escape_string($conn, $username);
    $injeksi_password = mysqli_real_escape_string($conn, $password);

    if (!ctype_alnum($injeksi_username) OR !ctype_alnum($injeksi_password)){
        header("Location:".base_url()."/404");
    }else{
        $query  = "SELECT * FROM users WHERE username='$username' AND password='$password'";
        $login  = $conn->query($query);
        $verify = $login->num_rows;
    $v      = $login->fetch_array();

1 个答案:

答案 0 :(得分:0)

用户base_url()代替了$_SERVER['SERVER_NAME'];

它返回当前URL,但仅返回路径部分。

For a guide on $_SERVER variables.