Jump to content

Recommended Posts

hello, 

i am new in php and i would like to develop a login screen in android. my server side is developed in php and for some reason i get every request the follwoing error:

"no such file or directory". 

i have 1 index file and 3 files insdie the "include" directory.

this is my files code:

index.php

<?php
/**
 * Created by PhpStorm.
 * User: matant
 * Date: 4/29/2015
 * Time: 4:57 PM
 */
$data = $_SERVER['HTTP_JSON'];
$data = json_decode($data);
$temp = $data->tag;


if($temp == 'login')
{
    $tag = $data->tag;
    $temp = 'insdieif';
    require_once 'include/DB_Functions.php';
    $db = new DB_Functions();

    $response = array("tag" => $tag, "error"=>FALSE);
    //login
    if($tag == 'login')
    {
        $email = $data->email;
        $password = $data->password;

        $user = $db->getUserDet($email,$password);

        if($user != false){
            $response["error"] = FALSE;
            $response["user"]["username"] = $user["usern"];
            $response["user"]["email"] = $user["email"];
            echo json_encode($response);

        }else
        {
            $response["error"] = true;
            $response["error_msg"] = "Incorrect Email or Password!";
            echo json_encode($response);
        }

    }else
    {
        $response["error"] = true;
        $response["error_msg"] = "This is not Login request!";
        echo json_encode($response);
    }

} else {

    $response["tag"] = $temp;
    $response["error"] = true;
    $response["error_msg"] = "tag parameter is missing";
    echo json_encode($response);
}

DB_Functions.php

<?php
/**
 * Created by PhpStorm.
 * User: matant
 * Date: 4/29/2015
 * Time: 3:57 PM
 */
class DB_Functions
{
    private $db;

    function _contrust()
    {
        require_once 'DB_Connect.php';
        $this->db = DB_Connect();
        $this->db->connect();
        echo $this->db;
    }

    function _destruct()
    {
        // $this->close();
    }

    public function getUserDet($email, $pass)
    {
        $res = mysql_query("SELECT * FROM users WHERE email = '$email'") or die (mysql_error());

        $num_of_rows = mysql_num_rows($res);
        if ($num_of_rows > 0) {
            $res = mysql_fetch_array($res);
            $restemp = $res['password'];
            if ($pass == $restemp)
                return $res;
            else
                return false;
        }

    }

}
?>

DB_Connect.php:

<?php
/**
 * Created by PhpStorm.
 * User: matant
 * Date: 4/29/2015
 * Time: 3:47 PM
 */

class DB_Connect{

    function _construct(){

    }

    function _destruct(){

    }

    public  function connect(){
        require_once 'Config.php';

        $con = mysql_connect("DB_Host","DB_User","DB_password");
        if(!$con)
        {
            die('could not connect:'.mysql_error());
        }
        else {
            mysql_select_db(DB_database, $con);
        }
        return $con;
    }

    public function close() {
        mysql_close();
    }
}
?>

Config.php:


<?php
/**
 * Created by PhpStorm.
 * User: matant
 * Date: 4/29/2015
 * Time: 3:35 PM
 */
define("DB_Host","sqlserver");
define("DB_User","user");
define("DB_password","pass");
define("DB_database","b12_16183751_gpsport");
?>

From the code your posted the "no such file or directory" message is not from your PHP code.

 

It is most likely the default 404 file not found error message from your server. Are you sure all files are named and placed in the correct directory on your server?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.