• All
  • Free Web Hosting
  • Category 2

Archives

gravatar

Creating DBInstance in PHP with Firebird Database

Im back! It's time to Code! Code! Code!, Let's say,......... Coding is much exciting than going to beach.... hahah, Anyway. Let's Start with the new coding technique.

CREATING DBINSTANCE in PHP with FIREBIRD DATABASE

<?php

class DBInstance{

    private static $instance;
   
    private static $engine;
    private static $dbkey;

    private static $database;
    private static $username;
    private static $password;
    private static $charset;
    private static $buffers;
    private static $dialect;
    private static $role;
    private static $port;
    private static $host;


    private static $message;


    protected function  __construct() {}
    protected function  __clone() {}

    public static function init(){
         $file = parse_ini_file("DBConnect/config.ini",true);
         try{
            self::$database = $file[self::$dbkey]['database'];
            self::$username = $file[self::$dbkey]['user'];
            self::$password = $file[self::$dbkey]['password'];
            self::$charset  = $file[self::$dbkey]['charset'];
            self::$buffers  = $file[self::$dbkey]['buffer'];
            self::$dialect  = $file[self::$dbkey]['dialect'];
            self::$role     = $file[self::$dbkey]['userrole'];
            self::$port     = $file[self::$dbkey]['port'];
            self::$host     = $file[self::$dbkey]['host'];
         }catch(Exception $e){
           self::$message = "config.ini cannot be found.";
         }

    }

    public static function setDBase($dbase){
        self::$dbkey = $dbase;
    }

    public static function setDBEngine($dbengine){
        self::$engine = $dbengine;
    }

    public static function getInstance(){
        if(!self::$instance){
            self::init();           
            if(self::$engine == "FireBird"){
                self::$instance = ibase_connect
                    (
                        self::$host . "/" . self::$port . ":" . self::$database,
                        self::$username, self::$password, self::$charset,
                        self::$buffers, self::$dialect, self::$role
                    );
                    self::$message = "You are now connected to systems database.";
                    if(ibase_errcode()){
                        self::$message = "Ooops... Something went wrong, Unable to establish database connection";
                    }
            }

            if(self::$engine == "MySQL"){
                 self::$message = "MySql Not yet been Implemented";
            }
        }
        return self::$instance;
    }
    public static function getDbError(){
        return self::$message;
    }
   
}
?>

gravatar

Kevern Solutions: Time To Relax! No Codes for a Week! Beach Time!

Kevern Solutions: Time To Relax! No Codes for a Week! Beach Time!: "For me as a peaceful person, I recommend this beach for those people who loves peace and solemn place to spend summer. This beach is located..."

gravatar

Time To Relax! No Codes for a Week! Beach Time!

For me as a peaceful person, I recommend this beach for those people who loves peace and solemn place to spend summer. This beach is located in the island of Philippines, The island name is Canigao Island, part of Matalom Leyte, Visayas Area. This beach is not yet fully developed, but cottages and shelters are available or D.I.Y., The thing is this island has no supply of electricity, but Electric Generators are being used during night to supply the Island Residents. Now this is Peace and quite for me. Anyway if you love music, you can bring your own, Now a days I don't anymore know if Hotels are available.




Things you may need if you visit this place:
12Volts Battert or any car Battery + Handy Power Converter (For Charging your Gadgets/Cellphones)
-Power Converter may be purchased at any Hardware Center (DIY stores/CD -R King)
Portable CD/DVD Players or Laptops
Portable Speakers/PC Speakers
Mosquito Repellents (OFF Lotions)
LED Lamps

gravatar

Kevern Solutions: Submit Banner (For Web Advertising) in PHP.

Kevern Solutions: Submit Banner (For Web Advertising) in PHP.: "This is a php based web program, no database included on this project, this system only upload specific images into you web server and send ..."

gravatar

Submit Banner (For Web Advertising) in PHP.

This is a php based web program, no database included on this project, this system only upload specific images into you web server and send confirmation massage to the user via auto email. System also limits the filesize upon upload and also user image gallery on page.

Screen Shots:

System Main Form1
Main Form
Data Entered
After Image Submission
User Checks His/Her Email
The Upload Summary
Download and extract 7zip file into your php root folder. Make sure that you have already configure your apache and php before extracting the file.

Good Luck!

Here is the link: http://www.4shared.com/dir/JgImBxI1/Banner_Advertising.html

gravatar

Kevern Solutions: Combo box validation in Javascript

Kevern Solutions: Combo box validation in Javascript: " This is a very simple way to check empty or invalid values in php Combo Boxes. Simple yet functional. Simply copy and paste this scrip..."

gravatar

Combo box validation in Javascript

 This is a very simple way to check empty or invalid values in php Combo Boxes. Simple yet functional. Simply copy and paste this script in,to your source code. This script is fully tested by me.

function ValidateCPA(calculate){

if (calculate.('cpa').chacked == false){
         alert ( "CPA Board Passer Information is required." );
         document.getElementById('cpa1').focus();
         return false;
         }
   
}

gravatar

Kevern Solutions: No numbers allowed in textbox in Javascript.

Kevern Solutions: No numbers allowed in textbox in Javascript.: " This script is very useful most specially if we want no numeric characters to be inputed in our textbox, and so, to eliminate those nu..."

gravatar

No numbers allowed in textbox in Javascript.

 This script is very useful most specially if we want no numeric characters to be inputed in our textbox, and so, to eliminate those numeric keys, just simply use this script. Thanks to the original author of this script.

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
    var key;
    var isCtrl = false;
    var keychar;
    var reg;
       
    if(window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }
   
    if (isNaN(key)) return true;
   
    keychar = String.fromCharCode(key);
   
    // check for backspace or delete, or if Ctrl was pressed
    if (key == 8 || isCtrl)
    {
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
   
    return isFirstN || isFirstD || reg.test(keychar);
}

/*This script is running and tested by me personally.
*/

gravatar

Upload File Size Limit in IE.

function IELimmit()
{
    var myFSO = new ActiveXObject("Scripting.FileSystemObject");
    var filepath = document.calculate.uploaded_file.value;
    var thefile = myFSO.getFile(filepath);
    var size = thefile.size;
   
        if (size > 2097152) {
    alert ("Unable to proceed upload, File is larger than 2mb.\nPlease upload only files less than 2mb.");
    return false;
    }
    return true;
}

//this code is tested and running.

gravatar

Only five zeros as default in Javascript.

function removeZeros(){

          if (document.getElementById('SSS_No').value == '0'){
        document.getElementById(''SSS_No').value = '0'   
        }
       
         if (document.getElementById('sss_no').value == '00'){
         document.getElementById('sss_no').value = '00'
         }
       
         if (document.getElementById(''SSS_No').value == '000'){
         document.getElementById(''SSS_No').value = '000'
         }
       
         if (document.getElementById(''SSS_No').value == '0000'){
         document.getElementById(''SSS_No').value = '0000'
         }
       
         if (document.getElementById('sss_no').value == '00000'){
         document.getElementById('sss_no').value = '00000'
         }
       
         if (document.getElementById(''SSS_No').value == '000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
         if (document.getElementById(''SSS_No').value == '0000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
         if (document.getElementById(''SSS_No').value == '00000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
          if (document.getElementById(''SSS_No').value == '000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
          if (document.getElementById(''SSS_No').value == '0000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
         if (document.getElementById(''SSS_No').value == '00000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
         if (document.getElementById(''SSS_No').value == '000000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
          if (document.getElementById(''SSS_No').value == '0000000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
          if (document.getElementById(''SSS_No').value == '00000000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }
       
         if (document.getElementById(''SSS_No').value == '000000000000000'){
         document.getElementById(''SSS_No').value = '00000'
         }

}
Here in this script, you must create a textbox, allow that textbox to be edited by the user, Now only five(5) zeros(0) will be accepted on that textbox, If the user inputed less or greater than five zeros and on lostfocus the textbox still gives a default of five zeros.

Try this script, and hope you can still develop this script.

Good Luck!!!

gravatar

Checking file size on upload in php

<?php
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) {
  //Check if the file is JPEG image and it's size is less than 350Kb
  $filename = basename($_FILES['uploaded_file']['name']);
  $ext = substr($filename, strrpos($filename, '.') + 1);
  if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") &&
    ($_FILES["uploaded_file"]["size"] < 350000)) {
    //Determine the path to which we want to save this file
      $newname = dirname(__FILE__).'/upload/'.$filename;
      //Check if the file with the same name is already exists on the server
      if (!file_exists($newname)) {
        //Attempt to move the uploaded file to it's new place
        if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
           echo "It's done! The file has been saved as: ".$newname;
        } else {
           echo "Error: A problem occurred during file upload!";
        }
      } else {
         echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";
      }
  } else {
     echo "Error: Only .jpg images under 350Kb are accepted for upload";
  }
} else {
 echo "Error: No file uploaded";
}
?>

gravatar

How to send mail in php?

<?php
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'YourSite.com.ph' . "\r\n";
$email = "test@yahoo.com"; //you can make this a dynamic one.
$subject = "test";
$message = "Name:"
            . "       "
//            . $name
            . "\n"
            . "Age:"
            . "\n"
            . "Address:"
            . "        "
//            . $address
//            . "\n"
            . "Email:"
            . "    "
            . $email;
            . "\n"
            . "===================================================="
            . "\n"
            . "* This is a system-generated e-mail. Do not reply.
";

mail($email, $subject, $message, "From: $headers");
?>

gravatar

Kevern Solutions: how to loop years in php?

Kevern Solutions: how to loop years in php?: " Create a drop down or a combo box and insert the code below: Author: Kevern V. <?php &nbsp..."

gravatar

how to loop years in php?

 Create a drop down or a combo box and insert the code below:

Author: Kevern V.

 <?php
          echo "<select name='ins' id='ins' class='yearstyle' onchange=\"computeAge(this.value);\">";
          for($i=1950;$i<=date('Y');$i++){
           echo "<option value='" . $i . "'>" . $i . "</option>";

        }
        echo "<option value='select' selected>Year</option>";
           echo "</select>";
      ?>

//1950 is hard coded, depends on your starting year choice. just make sure that the present year is not hard coded so that it will change depends on the current year.