Showing posts with label errors. Show all posts
Showing posts with label errors. Show all posts

Monday, June 27, 2016

Email Errors To Yourself Instead Of Showing It Publicly

Most servers are set to display an error message when an error occurred in one of your script. But, you may also want to get an email containing the error, instead of displaying it to the public.

The Script is given below:

<?php

// Our custom error handler
function nettuts_error_handler($number, $message, $file, $line, $vars){
$email = "
<p>An error ($number) occurred on line
<strong>$line</strong> and in the <strong>file: $file.</strong>
<p> $message </p>";

$email .= "<pre>" . print_r($vars, 1) . "</pre>";

$headers = Content-type: text/html; charset=iso-8859-1 . " ";

// Email the error to someone...
error_log($email, 1, you@youremail.com, $headers);

// Make sure that you decide how to respond to errors (on the users side)
// Either echo an error message, or kill the entire project. Up to you...
// The code below ensures that we only "die" if the error was more than
// just a NOTICE.
if ( ($number !== E_NOTICE) && ($number < 2048) ) {
die("There was an error. Please try again later.");
}
}

// We should use our custom function to handle errors.
set_error_handler(nettuts_error_handler);

// Trigger an error... (var doesnt exist)
echo $somevarthatdoesnotexist;
 
Hope You Enjoyed Reading this Post.

Friday, June 3, 2016

VDaemon PHP Library To Check User Input For Errors

An important aspect of creating Web Form pages is to be able to validate that the information users enter is correct. Handling errors in a Web Forms is a mandatory task for any true professional. It is not a difficult job to write this on PHP or JavaScript, but writing this more than once can quickly become a tedious nightmare.

What is VDaemon?

VDaemon is a PHP library that grants an easy-to-use but powerful way to check user input for errors, and, if necessary, display messages to the user.

What can VDaemon do?

  • VDaemon PHP script performs server-side validation using PHP and client-side validation using JavaScript.
  • VDaemon can perform wide range of validation tasks. It includes mandatory fields validation, validation for properly formatted value (currently supported types are e-mail address, zip codes for US, Canada and UK, US phone number, IP address, date and time in various formats, integer and floaf numbers, currency), comparing entered value to the predefined value or to another form element value, validating against regular expression pattern and more.
  • VDaemon allows combining validation rules into logical expressions of any complexity. It gives possibility to create a conditional validation.
  • VDaemon allows to highlight invalid form elements and/or corresponding labels by assigning them an alternative CSS styles. It automatically sets focus to the first invalid form element.
  • VDaemon can collect and display all error messages in one place on a page.
  • VDaemon leaves the behaviour of HTML forms unchanged. This allows easy incorporation of VDaemon validation into existing web sites.
  • VDaemon produces XHTML compliant code.
  • And more ...
Requirements

PHP version 4.2.0 or later is required for server-side validation.

Client-side validation is supported for the following browsers:
- IE 5 and later
- Firefox 1.0 and later
- Opera 7 and later
- Netscape 7 and later
- Safari 2.0 and later

Download VDaemon PHP Script