amirsanni / Mini-Inventory-and-Sales-Management-System

An Inventory and Sales Management System written in PHP (codeIgniter) with support for MySQL and Sqlite3 databases
https://1410inc.xyz/mini-inventory-and-sales-management-system/
MIT License
493 stars 270 forks source link

Error #9

Closed MorganBeukes closed 7 years ago

MorganBeukes commented 7 years ago

Error, Need help

An Error Was Encountered

Unable to load the requested class: Email

amirsanni commented 7 years ago

Can you send a screenshot? Also ensure you downloaded the complete project, perhaps one or more files are missing.

Grzegorz07 commented 7 years ago

Hello, i've got a problem. I can't log in, alwayes I have info "Log in failed. Please check your internet connection and try again later."

amirsanni commented 7 years ago
  1. Did you follow the instruction in the readme?
  2. Are you seeing any error in your developer console?
  3. How did you set the app up?
  4. Can I see screenshots?
raaaaay-c commented 7 years ago

I have the same problem, it seems some folder/ files are missing : image

the function handleLogin(....) in main.js is trying to ajax "appRoot+access/login", but there is no such directory in the whole project.

function handleLogin(email, password, callback){
    var jsonToReturn = "";

    $.ajax(appRoot+'access/login', {
        method: "POST",
        data: {email:email, password:password}
    }).done(function(returnedData){

        if(returnedData.status === 1){
            jsonToReturn = {status:1, msg:"Authenticated..."};
        }
        else{
            //display error messages
            jsonToReturn = {status:0, msg:"Invalid email/password combination"};
        }   
        typeof(callback) === "function" ? callback(jsonToReturn) : "";

    }).fail(function(){
        //set error message based on the internet connectivity of the user
        var msg = "Log in failed. Please check your internet connection and try again later.";
amirsanni commented 7 years ago

@raymonduui There are no files missing. The URI "access/login" is be re-routed to "home/login".

image

Ensure your appRoot and the other setup steps are properly followed.

amirsanni commented 7 years ago

@raymonduui From your screenshot, I can see that you're trying to access localhost:8080/access/login. Is it that the app is directly (not in any folder) inside your public_html OR www OR htdocs etc folder?

raaaaay-c commented 7 years ago

@amirsanni

Configs for hosting on Apache

My App Location : C:\Apache24\htdocs\mini-inventory-and-sales-management-system (where index.php is located )

Launch the app via : localhost/mini-inventory-and-sales-management-system

In httpd.conf

DocumentRoot "c:/Apache24/htdocs/"
<Directory "c:/Apache24/htdocs/">
......
AllowOverride All
DirectoryIndex index.php
</Directory>

For .htaccess in the root mini-inventory-and-sales-management-system Stays RewriteBase /mini-inventory-and-sales-management-system

For application/config/config.php Stays ."/mini-inventory-and-sales-management-system/"

For public/js/main.js Stays var appRoot = setAppRoot("mini-inventory-and-sales-management-system", "mini-inventory-and-sales-management-system");

raaaaay-c commented 7 years ago

Changed to sqlite, able to login with default email and password ,but redirected back to login page.... The front is stays in login page, but the back end is logged in already. image

amirsanni commented 7 years ago

@raymonduui Can you share your config/config.php file? And maybe your config/database.php as well.

raaaaay-c commented 7 years ago

@amirsanni Thank you. in config.php, I only remove the "/mini-...." after $protocol.$host as above mentioned.

$host = $_SERVER['HTTP_HOST'];//e.g practa.ng || www.practa.ng || localhost
$protocol = is_https() ? "https://" : "http://";

if(is_cli()){
    $config['base_url'] = "";
}

else if(stristr($host, "localhost") !== FALSE || (stristr($host, "192.168.") !== FALSE)|| (stristr($host, "127.0.0.") !== FALSE)){
    $config['base_url'] =  $protocol.$host;
}

else{
    $allowed = ['www.1410inc.xyz', '1410inc.xyz'];//input all allowed urls here e.g. amirsanni.com, www.practa.ng, smartagapp.com

    $config['base_url'] = in_array($host, $allowed) ? $protocol.$host: "http://".$_SERVER['HTTP_HOST']."/";
}

database.php is the same as from git, I didn't do any changes.

amirsanni commented 7 years ago

Add "/" after $protocol.$host.

It should look like this $config['base_url'] = $protocol.$host."/";

amirsanni commented 7 years ago

@raymonduui Also ensure codeIgniter is able to connect to your database.

raaaaay-c commented 7 years ago

@amirsanni thank you for answering.

I have added the ."/" and codeigniter is conected database.. but the same.. which server are you using to set up ?

amirsanni commented 7 years ago

@raymonduui Apache2 and I didn't change the document root (htdocs) as set by xampp.

Grzegorz07 commented 7 years ago

I have problem that all the time is Authenticating:

[image: Obraz w treści 1]

2017-09-07 12:14 GMT+02:00 Amir notifications@github.com:

@raymonduui https://github.com/raymonduui Apache2 and I didn't change the document root (htdocs) as set by xampp.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/amirsanni/Mini-Inventory-and-Sales-Management-System/issues/9#issuecomment-327757243, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlhFFn7pfq56xxrnJHtudaBssHp_jNwks5sf8IKgaJpZM4PA374 .

-- Pozdrawiam, Grzegorz Dąbrowski

Grzegorz07 commented 7 years ago

ERROR:

127.0.0.1/:86 GET http://127.0.0.1/public/js/main.js access.js:36 Uncaught ReferenceError: handleLogin is not defined at HTMLFormElement.loginForm.onsubmit (access.js:36)

2017-09-07 17:38 GMT+02:00 Grzegorz Dąbrowski grzesdab1@gmail.com:

I have problem that all the time is Authenticating:

[image: Obraz w treści 1]

2017-09-07 12:14 GMT+02:00 Amir notifications@github.com:

@raymonduui https://github.com/raymonduui Apache2 and I didn't change the document root (htdocs) as set by xampp.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/amirsanni/Mini-Inventory-and-Sales-Management-System/issues/9#issuecomment-327757243, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlhFFn7pfq56xxrnJHtudaBssHp_jNwks5sf8IKgaJpZM4PA374 .

-- Pozdrawiam, Grzegorz Dąbrowski

-- Pozdrawiam, Grzegorz Dąbrowski

Grzegorz07 commented 7 years ago

If you can help me per TeamViewer i would be very gratefull

2017-09-07 17:39 GMT+02:00 Grzegorz Dąbrowski grzesdab1@gmail.com:

ERROR:

127.0.0.1/:86 GET http://127.0.0.1/public/js/main.js access.js:36 Uncaught ReferenceError: handleLogin is not defined at HTMLFormElement.loginForm.onsubmit (access.js:36)

2017-09-07 17:38 GMT+02:00 Grzegorz Dąbrowski grzesdab1@gmail.com:

I have problem that all the time is Authenticating:

[image: Obraz w treści 1]

2017-09-07 12:14 GMT+02:00 Amir notifications@github.com:

@raymonduui https://github.com/raymonduui Apache2 and I didn't change the document root (htdocs) as set by xampp.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/amirsanni/Mini-Inventory-and-Sales-Management-System/issues/9#issuecomment-327757243, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlhFFn7pfq56xxrnJHtudaBssHp_jNwks5sf8IKgaJpZM4PA374 .

-- Pozdrawiam, Grzegorz Dąbrowski

-- Pozdrawiam, Grzegorz Dąbrowski

-- Pozdrawiam, Grzegorz Dąbrowski

amirsanni commented 7 years ago

@Grzegorz07 Let's do teamviewer in 4hrs. i.e. 9pm GMT+1

Grzegorz07 commented 7 years ago

ok, I will be waiting :) thx

2017-09-07 18:08 GMT+02:00 Amir notifications@github.com:

@Grzegorz07 https://github.com/grzegorz07 Let's do teamviewer in 4hrs. i.e. 9pm GMT+1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amirsanni/Mini-Inventory-and-Sales-Management-System/issues/9#issuecomment-327847097, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlhFB2Dr6iPqUCdfVg6iqxLSCmRrlHpks5sgBT1gaJpZM4PA374 .

-- Pozdrawiam, Grzegorz Dąbrowski

Grzegorz07 commented 7 years ago

your ID 292 891 474 password 9817

2017-09-07 18:17 GMT+02:00 Grzegorz Dąbrowski grzesdab1@gmail.com:

ok, I will be waiting :) thx

2017-09-07 18:08 GMT+02:00 Amir notifications@github.com:

@Grzegorz07 https://github.com/grzegorz07 Let's do teamviewer in 4hrs. i.e. 9pm GMT+1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amirsanni/Mini-Inventory-and-Sales-Management-System/issues/9#issuecomment-327847097, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlhFB2Dr6iPqUCdfVg6iqxLSCmRrlHpks5sgBT1gaJpZM4PA374 .

-- Pozdrawiam, Grzegorz Dąbrowski

-- Pozdrawiam, Grzegorz Dąbrowski

raaaaay-c commented 7 years ago

I would need your help too but I am in timezone GMT+8 , so if possible can we do teamviewer too ? now my database is connected, all paths are correct, but the uri rewrite is not working, even backend is loaded in , front end is refreshed but back to login page. image

amirsanni commented 7 years ago

@raymonduui when will you be available to do it? Now?

raaaaay-c commented 7 years ago

Nah not yet, I am still at work. but about 10PM (GMT+8 ), so 3PM (GMT +1 ) . Thanks

amirsanni commented 7 years ago

I won't be free at that time.

raaaaay-c commented 7 years ago

@amirsanni what time will you be free later today or Sat ?

amirsanni commented 7 years ago

8am GMT+1 tomorrow (Saturday). 3pm your time (I think)

Grzegorz07 commented 7 years ago

Hello, I have the same problem, If you find the problem, Please write me

Dnia 08.09.2017 o godz. 09:52 Amir notifications@github.com napisał(a):

Today 8am GMT+1 tomorrow (Saturday). 3pm your time (I think)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

raaaaay-c commented 7 years ago

@amirsanni I am ok at that time

Grzegorz07 commented 7 years ago

All the time I have problem with session, when you find the answer, why session doesn’t work, please write me

dnia 8 września 2017 o 17:25:36, Raymond Chu (notifications@github.com) napisał:

@amirsanni https://github.com/amirsanni I am ok at that time

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/amirsanni/Mini-Inventory-and-Sales-Management-System/issues/9#issuecomment-328134738, or mute the thread https://github.com/notifications/unsubscribe-auth/ANlhFI4qcER8w7QnFcJXmjEsdr_Eou8sks5sgVxwgaJpZM4PA374 .

raaaaay-c commented 7 years ago

@amirsanni Hi, I didn't have your response on Sat, but I found the problem is the routing, as from the php log , "No URI present. Default controller set", which is causing redirect to the default controller : home.

Problem is : $_SESSION['admin_id'] is empty

What's your structure and settings in xampp ? so I can follow it and test.

Now my structure is

xampp
  --htdocs
       --mini-inventory-and-sales-management-system
  --php
  --mysql
amirsanni commented 7 years ago

@raymonduui Sorry I could not meet up on Saturday. I'm using the default xampp settings. That's the same is @Grzegorz07 is having. The session data gets destroyed almost immediately. Can't tell what could be causing that at the moment. I'll check and get back.

raaaaay-c commented 7 years ago

@Grzegorz07 @amirsanni I fixed the issue :

  1. Go to system\libraries\Session\Session.php Comment out both sections: session_start(); at line 141 and

    // Security is king
        ini_set('session.use_trans_sid', 0);
        ini_set('session.use_strict_mode', 1);
           ini_set('session.use_cookies', 1);
           ini_set('session.use_only_cookies', 1);
           ini_set('session.hash_function', 1);
          ini_set('session.hash_bits_per_character', 4);

    at lines 313 to 319.

  2. Add session_start(); in index.php at root directory to a new line after <?php

Disable those security settings should be okay.

amirsanni commented 7 years ago

Just realised the issue is CodeIgniter's (version used) compatibility with PHP 7. Switched the one online to PHP 7 and same thing happened. I'd rather just update the framework.

amirsanni commented 7 years ago

@raymonduui @Grzegorz07 I have updated the framework. You can re-download and test.

raaaaay-c commented 7 years ago

Thank you ! It works perfectly fine now :)

amirsanni commented 7 years ago

Welcome

serpe99 commented 6 years ago

hello I want to tell you that the system looks good but the login error is still unresolved please can you give me a hand with that I am new in this world of php

amirsanni commented 6 years ago

Check #35

serpe99 commented 6 years ago

captura

amirsanni commented 6 years ago

What is the name of the folder the app is running from?

serpe99 commented 6 years ago

is a local server with ubuntu

\192.168.x.xxx\www\html

http://192.168.x.xxx/mini-inventory-and-sales-management-system/

amirsanni commented 6 years ago

Then you have to ensure your URL is well constructed i.e. really referencing that directory and that you have mod_rewrite enabled. From the screenshot, it says 404 Page Not Found meaning the link does not exist.

Also check the .htaccess file in the root directory. You should remove the directory name there since the app is hosted in the www/html directory.

serpe99 commented 6 years ago

is heading to this but it does not exist URL /mini-inventory-and-sales-management-system/access/login

amirsanni commented 6 years ago

Exactly what I said. It means the URL is not resolving properly.

serpe99 commented 6 years ago

change the name of all the files that you indicate but I am redirected to the same file I have to modify

jquery.min.js:4 POST http://192.168.1.136/mini-inventory-and-sales-management-system/access/login 404 (Not Found) send @ jquery.min.js:4 ajax @ jquery.min.js:4 handleLogin @ main.js:577 loginForm.onsubmit @ access.js:36

amirsanni commented 6 years ago

Did you check the .htaccess file?

serpe99 commented 6 years ago
RewriteEngine On RewriteBase /Inventory # Disable Directory Browsing Options All -Indexes #Removes access to the system folder by users. #Additionally this will allow you to create a System.php controller, #previously this would not have been possible. #'system' can be replaced if you have renamed your system folder. #RewriteCond %{REQUEST_URI} ^system.* #RewriteRule ^(.*)$ /index.php?/$1 [L] #When your application folder isn't in the system folder #This snippet prevents user access to the application folder #Submitted by: Fabdrol #Rename 'application' to your applications folder name. RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php?/$1 [L] #Checks to RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>

If we don't have mod_rewrite installed, all 404's

# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

serpe99 commented 6 years ago

new error image

amirsanni commented 6 years ago

RewriteBase /Inventory. Is the app inside a dir call Inventory? If no, remove Inventory and leave it as RewriteBase /.

As for the database error, this is a feature in the recent versions of mysql/mariadb. MySQL Doc. You will need to search on how to remove that restriction.

amirsanni commented 6 years ago

See this SO link on how to do that.