+ Reply Thread
#1


Hello, guys please help me look into this code and tell me why I get a different result when I upload this cold online.


but everything works fine offline.

the live site is ==> property.gidanjos.com

PHP version for local server is 5.5


Please help a learner. This is my first time of uploading a code online.


Even the CSS too is not working.




sessionStarter.php


    session_start();
    
    if(!isset($_SESSION['user'])){
            if(isset($_COOKIE['user']) && isset($_COOKIE['username'])){
                $_SESSION['user'] = $_COOKIE['user'];
                $_SESSION['username'] = $_COOKIE['username'];
            }else{
                header("Location: login.php");
                exit;
            }
    }

Header.php

<?php
require_once 'sessionstarter.php';
?>

     
 

Login.php

<?php
require_once 'sessionstarter.php';
?>




Coding Cage - Login & Registration System

    
   





    

           

    
        

        
            

                

Sign In.


           

        
            

                

           

            
                        if ( isset($errMSG) ) {
                
                ?>
                

                

                
               

                

                            }
            ?>
            
           

                

               
                
               

               
           

            
           

                

               
                
               

               
           

            
           

                

           

            
           

                
           

            
           

                

           

            
           

                Sign Up Here...
           

        
       

   
   

   
    




index.php

ob_start();
    session_start();
        //require_once 'header.php';
    require_once 'connect.php';
    
    // it will never let you open index(login) page if session is set
    if ( isset($_SESSION['user']) !="") {
        header("Location: home.php");
        exit;
    }
    
    $error = false;
    
    if( isset($_POST['btn-login']) ) {    
        
        // prevent sql injections/ clear user invalid inputs
        $username = trim($_POST['user']);
        $username = strip_tags($username);
        $username = htmlspecialchars($username);
        
        $pass = trim($_POST['pass']);
        $pass = strip_tags($pass);
        $pass = htmlspecialchars($pass);
        // prevent sql injections / clear user invalid inputs
        
        if(empty($username)){
            $error = true;
            $emailError = "Please enter your username.";
        }
//                else if ( !filter_var($username,FILTER_VALIDATE_EMAIL) ) {
//            $error = true;
//            $emailError = "Please enter valid email address.";
//        }
        
        if(empty($pass)){
            $error = true;
            $passError = "Please enter your password.";
        }
        
        // if there's no error, continue to login
        if (!$error) {
            
            $password = hash('sha256', $pass); // password hashing using SHA256
        
            $res=mysqli_query($dbc, "SELECT surveyor_id, username, password FROM surveyor WHERE username='$username'");
            $row=mysqli_fetch_array($res);
            $count = mysqli_num_rows($res); // if uname/pass correct it returns must be 1 row
            
            if( $count == 1 && $row['password']==$password ) {
                
                            //set the session
                            $_SESSION['user'] = $row['surveyor_id'];
                            $_SESSION['username'] = $row['username'];
                            
                            //set the cookie
                            setcookie('user', $row['surveyor_id'], time()+ (60 * 60 * 24 *30));
                            setcookie('username', $row['username'], time()+ (60* 60 * 24 * 30));
                            
                            header("Location: home.php");
            } else {
                $errMSG = "Incorrect Credentials, Try again...";
                                echo $password;
            }
                
        }
        
    }

home.php

//checking loging credentials

if ( isset($_SESSION['user']) !="") {
     header("Location: login.php");
     
     exit;
}else {


    
        //page header
        $page_title = 'Where Opposite attracts';
        require_once  'header.php';

        //connection variables
        require_once 'connect.php';

        //time setting
        date_default_timezone_set('UTC');
        $tommorrow = mktime(0, 0, 0, date('d')+1, date('m'), date('Y'));
        
       ?>
       

       

            
       
'>
              
       
       if(isset($_GET['deleted'])){
           echo $_GET['deleted'];
       }
       require_once  'retrieve.php';
       
       ?>
       

                  
       

       

       
          
       
       include 'footer.php';

   }


#2

There is an issue of case sensitivity, your development server is likely windows. On a real linux server, the file system is case sensitive.

So your css should reference

<link href="content/bootstrap.css" rel="stylesheet">

<link href="content/Site.css" rel="stylesheet">

i.e. the content folder should be smaller case.

#3
OK boss, noted
#4
dhtml wrote:

There is an issue of case sensitivity, your development server is likely windows. On a real linux server, the file system is case sensitive.

So your css should reference

<link href="content/bootstrap.css" rel="stylesheet">

<link href="content/Site.css" rel="stylesheet">

i.e. the content folder should be smaller case.

I have done the correction in all my files, the changes have reflected

#5

That is good, case is closed then. We need a button to mark a question as solved here o.

Back to top