简体   繁体   中英

I can run my project in xampp (localhost) but I cannot run when am trying run in another computer even after configuring

<?php
session_start();

define("HOST","localhost");
define("USER","root");
define("PASS","");
define("DB","project_inv");

define("DOMAIN","http://localhost/      
inv_project/public_html/dont");
?>

Database:

<?php

class Database
{
    private $con;

    public function connect(){
        include_once("constants.php");
        $this->con = new Mysqli(HOST,USER,PASS,DB);
        if ($this->con) {
            return $this->con;
        }
        return "DATABASE_CONNECTION_FAIL";
    }
}

//$db = new Database();
//$db->connect();

?>

JavaScript Validation Part: It comes here and keeps on loading when am trying to take from ip, eg http://xx.xx.xx.xx/inv_project/public_html/dont/

//For Login Part

$("#form_login").on("submit",function(){
        var email = $("#log_email");
        var pass = $("#log_password");
        var status = false;
        if (email.val() == "") {
            email.addClass("border-danger");
            $("#e_error").html("<span class='text-danger'>Please Enter Email Address</span>");
            status = false;
        }else{
            email.removeClass("border-danger");
            $("#e_error").html("");
            status = true;
        }
        if (pass.val() == "") {
            pass.addClass("border-danger");
            $("#p_error").html("<span class='text-danger'>Please Enter Password</span>");
            status = false;
        }else{
            pass.removeClass("border-danger");
            $("#p_error").html("");
            status = true;
        }
        if (status) {
            $(".overlay").show();
            $.ajax({
                url : DOMAIN+"/includes/process.php",
                method : "POST",
                data : $("#form_login").serialize(),
                success : function(data){
                    if (data == "NOT_REGISTERD") {
                        $(".overlay").hide();
                        email.addClass("border-danger");
                        $("#e_error").html("<span class='text-danger'>It seems like you are not registered</span>");
                    }else if(data == "PASSWORD_NOT_MATCHED"){
                        $(".overlay").hide();
                        pass.addClass("border-danger");
                        $("#p_error").html("<span class='text-danger'>Please Enter Correct Password</span>");
                        status = false;
                    }else{
                        $(".overlay").hide();
                        console.log(data);
                        window.location.href = DOMAIN+"/dashboard.php";
                    }
                }
            })
        }
    })

While am trying to run from other computer it displays the design and content of the page but it is not validating but when am trying locally it works fine.

Don't define DOMAIN as "localhost". This will cause errors, while calling the page from other computers.

Localhost means always the computer the script is running on. Using this in a JavaScript the reference to the server is lost and it tries to connect/forward to the client-computer - with no success. This works on the first computer, because this might be the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM