[Problem]Session in PHP server for Android app


  1. peacefreezer

    peacefreezer New Member

    I am trying to create a session to retrieve the login username for further usage, which is to create a directory name based on the login username. It is an app connect to the php server I am able to connect to the database. Login successfully. Creating the directory is successful too(in separated android project)

    When I try to add in session_start in the mkdir.php file. My login failed (even the individual project which contains the login function ONLY to the same database failed.)Login only works again once I remove the session_start from mkdir.php).Not only that, the app which contains login function is force to close.Other apps related to the same database was affected too.

    Please guide.The problem is on the mkdir.php I guess

    FAILED: mkdir.php
    PHP:
    <?php
    include "Header.php";
    include "localhost.php";
    include "main.php";

    $path = $_Session['username'].$_POST['Case_no'];
    mkdir($path);

    ?>
    Header.php
    PHP:
    <?php   session_start();
    include "localhost.php";

    if(!isset($_SESSION['username']))
    {
        ?>
         <a href="Login.php" />Login </a>
        <?
    }
    else
    {
      echo "welcome ".$_SESSION['username'];

      ?>
       <a href="Logout.php" />Logout </a>
      <?
    }

         ?>
    localhost.php is the connection to the database(it works)

    main.php
    PHP:
    <?php require_once('localhost.php'); mysql_select_db($database_localhost,$localhost);



    $username = $_POST['UserEmail'];

    $password = $_POST['Password'];



    $query_search = "select * from tbl_user where username = '".$username."' AND password = '".$password. "'";

    $query_exec = mysql_query($query_search) or die(mysql_error());

    $rows = mysql_num_rows($query_exec);

    $_SESSION['username']=$username;


    ?>
    SUCCESSFUL :mkdir.php

    PHP:
    <?php
    $path = $_POST['Case_no'];
    mkdir($path);

    ?>

    Advertisement
    :
Loading...

Share This Page