• support[@]kurinchilion.com
  • +1 (888) 666-4252

Tags

PHP: Program to pass data using character encoding (GET Parameter)

Oct 06, 2009 - by kurinchilamp / / Post Comment
PHP program to pass data as GET parameters
<?php
// PHP 5 how to pass data as a query string
/*
http_build_query is a function in PHP 5 that enables you to URL encode the query string. You can pass an array or an array of array to this function. The default separator is "&"
*/

$data = array("first_name" => "Robert",
                "last_name" => "Brown",
                "address" => "123 Adam St., New York"
            );

// URI formatted with character encoding
$pass_string = "http://localhost/demo.php?".http_build_query($data, '');

echo "<h2>Query URI (using http_build_query)</h2><br />";
echo $pass_string;            
?>
Ouput from the above execution: Query URI (using http_build_query) http://localhost/demo.php?first_name=Robert&last_name=Brown&address=123+Adam+St.%2C+New+York
Continue Reading

PHP: How to receive the posted XML data?

Oct 05, 2009 - by kurinchilamp / / Post Comment
Receive the posted XML data In order to test the posted data, we can create a file creation steps to ensure that we receive the posted data via the $_POST array
<?php
/* 
  File name: postdata2.php
*/
    $xmlFile = "xmlFile.txt";
    $fh = fopen($xmlFile, 'w') or die("Cannot open file");
    fwrite($fh, $_POST["xmldata"]);
    fclose($fh);



?>
Continue Reading

PHP removing deprecated related errors from display

Aug 31, 2009 - by kurinchilamp / / Post Comment
To remove deprecated warning message displays when executing PHP programs, open php.ini file and ADD to it error_reporting = E_ALL & ~E_DEPRECATED This is the setting for the production environment where you would not like to display the deprecated function related errors. Sample error message Assigning the return value of new by reference is deprecated in nusoap.php on line 7381
Continue Reading

CakePHP: Multi-validatable Behavior

Jul 21, 2009 - by kurinchilamp / / Post Comment
Consider the following scenario where we have a database table:users and that we need carry the validations for the following forms i) Login ii) Change password iii) Add/Edit user records iv) Forgot password You can either write separate controllers and have each controller call a model based on table: users to validate each input field or use the same user model to carry out different validations which sounds logical. It is easy to carry out different validations in a cakephp model by using the Multi-validatable Behavior by having different validation sets for different testing conditions. Key things to note here ... i) Download the code for Multivalidatable Behavior and have it placed under /models/behaviors/ folder ii) In the model where you want to have multi validation, you need to include multivalidatable behavior like var $actsAs = array("Multivalidatable"); iii) Add validation rulesets array like var $validationSets = array('login' => array('name'=>array('rule'=>'alphanumeric')), 'changepassword' => array('password'=>array('rule'=>'notEmpty')) ); iv) In the controller where you want to apply the validation rule set, you need to add the respective validation like function login(){ $this->User->setValidation('login'); } function changepassword(){ $this->User->setValidation('changepassword'); } For more info visit CakePHP Bakery
Continue Reading

How to turn off register_globals via php.ini?

Jul 16, 2009 - by kurinchilamp / / Post Comment
It is always secured to turn OFF register_globals in PHP applications. Earlier, we have seen how to turn OFF register_globals setting via .htaccess file and in this blog we will use php.ini instead. Using a text editor create a file called php.ini. This will be our first step. Next, we need to add the following line of code in php.ini register_globals = off Upload php.ini file to the root folder where your application resides.
Continue Reading

PHP Image Upload and Security

Jul 09, 2009 - by kurinchilamp / / Post Comment
List of steps to take care when using PHP to upload images or documents i) use is_uploaded() function to check if the file is uploaded before moving the file from temporary location ii) sanitize the name of the file before moving the file from the temporary location by executing the 'mv' system command (use escapeshellargs, escapeshellcmd as needed) iii) chmod the file setting to 644 if needed iv) the directory from where the file will be moved and the destination directory should be initialized beforehand in order to prevent users from altering the path where the files could be stored
Continue Reading

TECHNOLOGY DEV STACK

Following are some of the technologies that we use to build and maintain solutions for our clients.