Friday, 20 February 2015

Generate Excel Report in Codeigniter

Generate Excel Report in Codeigniter


1.Controller file its just for examplle

$data['excel_data'] = $this->excel_model->view();  (this value with array and in model you should be create view function)

2. View file


These 3 line for generate excel report those line should be top on the view file
<?php
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="DonationList.xls"');
header('Cache-Control: max-age=0');
?>
<table width="100%" border="1">
    <tr>
        <th>Id</th>
        <th>Donor Name</th>
</tr>
<?php foreach ($excel_data as $row): ?>
    <tr>
        <td><?php echo $row->id; ?></td>
        <td><?php echo $row->name; ?></td>
</tr>
</table>

once you run this type file in Codeigniter you get downloadable excel  sheet

Generate Excel Report in Codeigniter

Monday, 16 February 2015

How To Change Ring & Vibration Settings in Yureka



Here is the solution how to make ring with vibrate in YU Yureka




If you  not found the Sound option in click Plus(+) button on the top there will show the list you just select sound it will show in the list then you can change to ring and vibrate mode it will work 100%

Wednesday, 4 February 2015

How to Install Zend Framework

How to Install Zend Framework

Detail about How to install zend framework 2 in 5 steps


1.Download the zip file using below link

https://github.com/zendframework/ZendSkeletonApplication
after downloading the zip folder extract in and copy the all folders, paste it in your project folder example path : C:\xampp\htdocs\zend

2.Download the composer exe file from this url
https://getcomposer.org/Composer-Setup.exe
and install it while instaling time if it is give the error plz
open the php.ini file form this url example :  C:\xampp\php and Uncomment the line extension=php_openssl.dll by removing the semicolon at the beginning.
Now you are good to install Composer.

3.Open command prompt and open project folder path in command prompt example : c:xampp\htdocs\zend
and paste this code and run it for updating the composer : php composer.phar self-update

4.After this it will download 100% then you paste this code and run it for install the updated composer in same command prompt like : php composer.phar install

5.Finally its installed now you can open your website link in local  like

http://localhost/zend/public/

Example Screen will show





How to install zend framework




Thursday, 20 March 2014

Send Html Email in Codeigniter / HTML Email Configuration In Codeigiter



Variables load from config Folder autoload File Helper

Example : $autoload['helper'] = array('text','html','email');



//IMP to add this below 2 line for sending html email configuration



                $email_setting = array('mailtype' => 'html');

                $this->email->initialize($email_setting);

                //IMP


                $this->email->to('admin@gmail.com');

                $this->email->from('admin@gmail.com');

                $emailmsg = "Message : Hi This is Test Mail";

                $emailmsg.= "<table width='50%' border='0'>
    <tr><td>Name : </td>
    <td>Stive Jobs </td>
   </tr>
   <tr><td>Address : </td>
   <td>#151 5th main 3rd Cross United State Of America</td>
   </tr></table>";

                $this->email->message($emailmsg);

                $this->email->send();




Send Html Email in Codeigniter / HTML Email Configuration In Codeigiter

Saturday, 30 November 2013

Login Code in PHP

In this tutorial, we create 3 php files for testing our code.

1. index.php
2. logincheck.php
3. success.php

4 Steps to create login page

1. Create table "userlist" in database "demo".
2. Create file index.php.
3. Create file logincheck.php.
4. Create file success.php.

Create file index.php.


<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form" method="post" action="logincheck.php">
<td>
<table width="100%" border="0" cellpadding="2" cellspacing="2" bgcolor="#000">
<tr>
<td colspan="3"><strong>Login Page</strong></td>
</tr>
<tr>
<td width="78">Userid / Email id</td>
<td width="6">:</td>
<td width="294"><input name="txtusername" type="text" id="txtusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="txtpassword" type="text" id="txtpassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

Creating database with table and data


CREATE TABLE `userlist` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

INSERT INTO `userlist` VALUES (1, 'admin', 'admin123');


Create logincheck.php page

<?php

$host="localhost"; // Host name
$username=""; // username
$password=""; // password
$dbname="demo"; // Database name
$tblname="userlist"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");

// username and password sent from form
$txtusername=$_POST['txtusername'];
$txtusername=$_POST['txtpassword'];

// To protect MySQL injection (more detail about MySQL injection)
$txtusername= stripslashes($txtusername);
$txtusername= stripslashes($txtusername);
$txtusername= mysql_real_escape_string($txtusername);
$txtusername= mysql_real_escape_string($txtusername);
$sql="SELECT * FROM $tblname WHERE username='$txtusername' and password='$txtusername'";
$result=mysql_query($sql);

// Counting table row
$row=mysql_num_rows($result);

// If  matched $txtusernameand $txtusername, table row must be 1 row
if($row==1){

// Register redirect to file "success.php"
session("txtusername");
session("txtusername");
header("location:success.php");
}
else {
echo "Invalid Username or Password";
}
?>

Create Success Page


<?php
session_start();
if(!session_is_registered(txtusername)){
header("location:index.php");
}
?>

<html>
<body>
Login Successful
</body>
</html>

PHP database Connection


<?php
$dbhost = 'localhost:1080';
$dbuser = 'username'; // in local root is default username
$dbpass = 'password';
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $con )
{
  die('connection error : ' . mysql_error());
}
echo 'Connected successfully';
$sql = 'CREATE Database test_database';
$query= mysql_query( $sql, $conn );
if(! $query )
{
  die('Not create database: ' . mysql_error());
}
echo "Database created successfully\n";
mysql_close($conn);
?>

Mail Function in PHP

How to send mail in php

Mail Function in PHP


<html>

<body>

<?php

if (isset($_REQUEST['email']))

//if "email" is filled out, send email

  {

  //send email

  $email = $_REQUEST['email'] ;

  $subject = $_REQUEST['subject'] ;

  $message = $_REQUEST['message'] ;

  mail("someone@example.com", "Subject: $subject",

  $message, "From: $email" );

  echo "Thank you for using our mail form";

  }

else

//if "email" is not filled out, display the form

  {

  echo "<form method='post' action='mailform.php'>

  Email: <input name='email' type='text'><br>

  Subject: <input name='subject' type='text'><br>

  Message:<br>

  <textarea name='message' rows='15' cols='40'>

  </textarea><br>

  <input type='submit'>

  </form>";

  }

?>

</body>

</html>


Mail Function in PHP