PHP Frameworks

HTML Media Capture

Author - Shalini

How to access Camera and upload the image/video to server?

We can achieve above requirements easily by using HTML Media Capture :
<form action=”upload.php” method=”post” enctype=”multipart/form-data”>

Capture Image: <input type=”file” name=”uploadedfile” accept=”image/*” capture=”camera”>

<input type Read more…

Moodle | How to create a scheduled task in moodle

Author - Kritika Sood

In moodle we can create scheduled tasks which will run after a defined interval. We also have cron jobs in moodle but they usually run after every minute so if we need to run a task after a particular time we need to create a scheduled task for this.

An Read more…

CakePHP 3.x or 2.x | Some important configuration settings

Author - Rita

Some important settings that can help you while working with CakePHP 3 or 2.

1. How to set Homepage for your website in CakePHP 3?

Go to the root directory of your project. You will see config folder there. Inside Config
folder, open routes.php file. Add below the line Read more…

Salesforce | Get list of Salesforce sobjects and fields in PHP

Author - Webner

Problem: How to get list of all the Salesforce sobjects in php. Also get fields of each sobject.

Solution: First we need to install Salesforce php toolkit for this. Once you have it then this is the sample code:
require_once(SFDCPHPtoolkit / soapclient / SforcePartnerClient.php ‘);
$mySforceConnection = new Read more…

phpMyAdmin | Different methods to View Table Constraints

Author - Ishpreet Kaur

How to view List of constraints of tables of Database in phpMyAdmin

There are various ways by which we can view the list of constraints applied to tables of given database in PhpMyadmin. Let’s see few methods here:

Suppose we have a database named CollegeDb Read more…

Explanation of Column3 in Moodle/Totara

Author - Kajal Marwaha

Column 3 layout in Moodle is basically dividing the screen into 3 parts .

user setting options Layout (pre )
content layout (region)
editing layout (post)

user setting options Layout (pre): In column3 layout pre region is the first column. This column is at  the left of the content. This Read more…

Purpose of Security.salt and Security.cipherSeed in CakePHP

Author - Ashish

cipherSeed in CakePHP
cipherSeed is used in Security::cipher() function to seed rand(). Seed means to give the initial value to rand() function to start and based on that the future values by rand() function are generated. In php, before 4.2.0 version, Random Number Read more…

Heroku | The datasource configuration “default” was not found in database.php

Author - Webner

Heroku throwing ERROR: “The datasource configuration “default” was not found in database.php” with database configuration already present for cakephp app.

In one of our cakephp projects hosted on Heroku we used PostgreSql database. For configuring the database to connect to app code we renamed the database.php.default file Read more…

CakePHP Security Component

Author - Manju Kashyap

CakePHP Security Component is very useful and provides an easy way to enable very tight security in our application:

1. It can restrict which HTTP methods our application accepts.
2. It provides Form Tampering Protection.
3. It can force to require that SSL must be used.
4. It Read more…

Moodle | Add and access custom elements in Blocks

Author - Kritika Sood

In Totara how to add custom HTML elements (checkboxes, input boxes etc) and then access the value selected by user on server side:

1. Adding custom elements.
2. Accessing values of custom elements.

Each problem is discussed below: Overview:

In Totara, for blocks, we have some Read more…

Shopify webhook getting fired multiple times and then getting deleted from shopify store

Author - Webner

In our Shopify store we have an order creation webhook that points to a cakephp action URL. The action that webhook points to fetches the order data and then saves this to the database.

The problem that we were facing with this webhook was that it was getting invoked multiple Read more…

WordPress | Get title and description from posts dynamically

Author - Neelam

In wordpress we can get title from post title and description from post content area dynamically:
$id = get_the_ID();          //get the post id.
$title = get_the_title($id);           //get title from the post.
$content = get_post_field(‘post_content’, $id);     // Get all content from post content area.
$trimmed_content = wp_trim_words( $content, 20, ‘….’ ); // This function trims Read more…

Sorting Alphanumeric Data in PHP

Author - Kritika Sood

While fetching data from database, in SQL query I had ‘order by’ clause but the results were not sorted when the data was in alphanumeric form. The reason for this is that SQL sorts character by character from left to right. So it places c10 before c2 as 1&lt Read more…

CakePHP | How to handle special characters (like apostrophes) in queries

Author - Ishpreet Kaur

Let us take an example:

We have table employees with following fields:

id int primary key,

name varchar(50),

city varchar(50)

We have following records in the table:

(1, isha, amr);

(2, Hamlet’s, ghy);

(3, éhjj, amr);

2nd and 3rd records have special characters in their Read more…

MySQL | Unable to create foreign key between two tables

Author - Webner

We have two tables say table1 and table 2. In table 1, there is a field named Id and this field is set as primary key in table 1. We want to use it as foreign key in table 2.

Fields in both the tables:
Table 1
Id Read more…

MySQL | How to support European characters on database level

Author - Parminder Kaur

European characters like è é å ñ ü ,à, è, ì, ò, ù – À, È, Ì, Ò, Ù, ™, © ,• , ∑, α, β, «, » do not get inserted correctly in MySQL by default. To fix it, we need to change the character set (fixed collection of symbols) and collation (set of rules that determine how data is sorted and compared).

To insert and retrieve european characters change character set to utf Read more…

MYSQL | #1293 – Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP

Author - Ishpreet Kaur

Suppose we want to have columns created_date and last_modified_time with default timestamp in any table in MySQL/Phpmyadmin.

Let us take an example of Students table.

Create table Students using following query :
CREATE TABLE students(
first_name varchar(20) NOT NULL,
last_name varchar(20) NOT NULL Read more…

CakePHP | How to implement Internationalization in CakePHP 3.X

Author - Rita

To implement Internationalization, CakePHP will pick all your strings which start with “__(“ double underscore ) and generate a default file for you.

For Example: one of the strings defined in our project is as below:
echo __ ( ‘ Gift Cards Not available’ );
Replace all your normal string with (__ Read more…

PHP | Convert Special Characters to HTML entities without using htmlspecialchars( ) function

Author - Kritika Sood

We can’t use special characters like >,<,”,’ etc directly in code because browser mixes these characters with HTML tags and gets confused. So we can use HTML entities if we want to use special characters in our code.

Below are some common entities which we can use Read more…

How to access javascript array in php on submit

Author - Kritika Sood

Suppose you have a Javascript array and want to send it to the server side on page submit then you can use this method.

Suppose we have a Javascript array with 3 elements:
var test = [“test1”, “test2”, “test3”];
Now create a hidden variable in HTML. This variable will Read more…

‹ Prev page1 ... 3 4 5 6 7 8 9 10 11 12 13 Next page ›