How to send e-mail in CodeIgniter

CodeIgniter have built in email sending library you just need to load that library before the email function .

example is given bellow.

<?php

$this->load->library(’email’);

$this->email->from(’email@server.com’, ‘Your Name’);

$this->email->to(‘sender_email@server.com’);

$this->email->cc(‘another@ server.com’);

Read More…

CodeIgniter Disallowed Key Characters

Question is CodeIgniter is giving me a Disallowed Key Characters error. I’ve narrowed it down to the name attribute of a form field: name='prod[50-4121.5]' but I’m not sure what to do about it.

 

Answer is

Open libraries/Input.php (system/core/Input.php in CI version 2.0+) and locate function _clean_input_keys($str){, The whole block should look like so:

function _clean_input_keys($str)
{
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
Read More...

Cannot Modify Header Information – Headers Already Sent – Common PHP WordPress Issue Solution

Now a days many of us facing this issue Cannot modify header information- Headers already sent”

the simplest solutions of this issue is to find your wp-config.php and this this code on the first line of wp-config.php

Read more…

PHP Random Number / String Generator

Here are some methods by which you can generate random numbers / strings in PHP.

  1. There is a word called rand in php by which you can generate random numbers. Method is given bellow.

PHP RANDOM NUMBER

$random_value =rand();

echo $random_value.”</br>”;

  1. You can also give you range of numbers in rand() function . Syntex in given bellow

Read more…

How to make widgets in WordPress

Many of my fellow’s asked me about how to develop custom widgets in wordpress. so the answer is very simple follow the listed bellow steps and piece of code to get started.

1. first of all you need to find out the widget.php in your theme . if there is not widget.php you can create your own.

copy and paste the given code in widget.php

 

class bottom_widget_quote extends WP_Widget {

// Create Widget
function widget() {
parent::WP_Widget(false, $name = ‘Widget Name’, array(‘description’ => ”));
}

// Widget Content
function widget($args, $instance) {
extract( $args );
$title= strip_tags($instance[‘title’]);
$details= strip_tags($instance[‘details’]);

?>

More…

How to get select option value in JavaScript

There are many methods to get option value in javascript but in my view the simplest way to do that is to make function in javascript .

Following are the two methods are given follow any one of them to get the value of option.

<select  onchange=” myFunction()“>

<option value=”1”>One</option>

<option value=”2”>Two</option>

<option value=”3”>Three</option>

<option value=”4”>Four</option>

<option value=”5”>Five </option>

</sclect>

Method 1:-

<script>

function myFunction() {

 var x = document.getElementById(“customer_s”).selectedIndex;

alert(document.getElementsByTagName(“option”)[x].value);

}

</script>

Method 2:-

<script>

function myFunction() {

 var x = document.getElementById(“customer_s”).selectedIndex;

 var y= document.getElementsByTagName(“option”)[x].value;

window.location.href = “http://www.yoursite.com?user=” + y;

}

</script>