Welcome Guest, Not a member yet? Register   Sign In
Best Practice for Error handling
#1

(This post was last modified: 04-09-2016, 04:19 AM by ardavan.)

Hey,

I wonder how to avoid "A PHP Error was encountered" when user enter class/method manually to the url ?

actually i want to learn how can handle the errors and show the nice page to the users Also avoid to display my directory to the hackers  Dodgy

In my index.php file I've added
Code:
define('ENVIRONMENT', 'production');

Thanks for your time and helps guys
Have a good day  Wink
Reply
#2

Hi,

If someone tries to mess with the url you should get a 404 error page, which you can format in the errors/html folder in the view files.

Alternatively, if they mess with some of the values in your method, your method should be checking that, and posting an error page appropriately.

Hope that helps,

Paul.
Reply
#3

(This post was last modified: 04-09-2016, 07:29 PM by ardavan.)

(04-09-2016, 03:39 PM)PaulD Wrote: Hi,

If someone tries to mess with the url you should get a 404 error page, which you can format in the errors/html folder in the view files.

Alternatively, if they mess with some of the values in your method, your method should be checking that, and posting an error page appropriately.

Hope that helps,

Paul.

Hey Paul,

i know about the 404 error page which is in the view folder. but i wanna know how to set if someone input some class/method in my url.
Currently, for example, if you put something out of my classes or methods the page will redirect to 404 page . but if you input the correct class/method will show you this

I've added
Code:
http://example.com/index.php/early_access/provider'-

and I've got this page(which is i don't wanna see this)
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: HTTP_REFERER
Filename: html/error_general.php
Line Number: 62
Backtrace:
File: /.../.../public_html/.../application/views/errors/html/error_general.php
Line: 62
Function: _error_handler

File: /.../.../public_html/.../index.php
Line: 292
Function: require_once

i would like to change this page to 404 or redirect to homepage or whatever just i don't like to give them my application directory!

Thanks
Reply
#4

Hi,

Not sure how it is possible to have an error in your php for the error_general.php, since it just echos the title and the message.

Have you changed it, trying to use server headers to identify the source and redirect?

Personally I would not try to avoid the error pages as this can lead to more confusion that it solves, but they are in the view files specifically so you can format them however you want.

The php error you are getting above is something you need to locate and fix.

You should never be able to submit a url to one of your functions that can cause a php error, your own error checking should take care of that.

The error pages themselves, I have never experienced them throwing an error like that, so I presume you have customized them in some way.

Sorry I cannot be of more help,

Paul.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB