Monday 7 December 2015

HTML Page Title Marquee

<!-- Add the event loader to the body tag as below -->
<title> Marquee Use in HTML Page Title</title>

<body onLoad="scrlsts()">
<h1>TITLE MARQUEE</h1>
<h2> Marquee Use in HTML page title</h2>
</body>

<!-- Add the script to the HEAD of your document -->
<script LANGUAGE="JavaScript">
//alert(document.title);
<!-- Begin
var scrl = document.title+" ";

function scrlsts() {
 scrl = scrl.substring(1, scrl.length) + scrl.substring(0, 1);
 document.title = scrl;
 setTimeout("scrlsts()", 300);
 }
//  End -->
</script>

Thursday 3 December 2015

Remove  Characters in HTML

Thread: PHP - includes ( characters)

Try putting this after your <head> tag:

Code:
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

Friday 6 November 2015

CodeIgniter Remove index.php By .htaccess

Steps To Remove index.php using .htaccess

Step:-1  Open the file config.php located in application/config path.  Find and Replace the below code in config.php  file.

//  Find the below code

$config['index_page'] = "index.php"

//  Remove index.php

$config['index_page'] = ""

Step:-2  Go to your CodeIgniter folder and create .htaccess  file.

Path:
Your_website_folder/
application/
assets/
system/
user_guide/
.htaccess <--------- this file
index.php
license.txt
Step:-3  Write below code in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Step:-4  In some cases the default setting for uri_protocol does not work properly. To solve this issue just open the file config.php located in application/configand then find and replace the code as:
//  Find the below code

$config['uri_protocol'] = "AUTO"

//  Replace it as

$config['uri_protocol'] = "REQUEST_URI" 

Tuesday 3 November 2015

Family Tree In PHP

Create Family Tree In PHP


1st Step : Create these belove file and database
  - CSS : style.css, ddsmoothmenu.css, ddsmoothmenu-v.css
  - JS : ddsmoothmenu.js
  - HTML : tree.html
  - PHP   : index.php, add_member.php, data.php, update.php
       - Database Import : family_tree.sql


Download this Script Click Here

Monday 5 October 2015

Why Customised permalinks not working in localserver (WAMP) ?

 1st Way : 

For enabling pretty urls / permalinks, you have to enable Apache mod_rewrite.
1. Start WAMP Server. Click on the WAMP Server icon in the tray. Go to Apache -> httpd.conf link on the list. Click on that file link. It will open httpd.conf file in notepad.
2. Use the Find / Search function in Notepad and search for this line :
# LoadModule rewrite_module modules/mod_rewrite.so
Remove that hash and a space before :
LoadModule rewrite_module modules/mod_rewrite.so
Save it. Exit.
3. Restrat WAMP.
      Permalink will work.

 2st Way : 
1. Enable rewrite_module modules


Monday 7 September 2015

Resize Image

//image_resize.php

<?php
error_reporting(0);

$message = "";


 define ("MAX_SIZE","100000");
 function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }

 $errors=0;
 
 if($_SERVER["REQUEST_METHOD"] == "POST")
 {
$dir_path = "images";
  $image =$_FILES["file"]["name"];
$uploadedfile = $_FILES['file']['tmp_name'];

$newheight = $_POST['image_height'];
$newwidth = $_POST['image_width'];

  if ($image)
  {
 
  $filename = stripslashes($_FILES['file']['name']);
 
  $extension = getExtension($filename);
  $extension = strtolower($extension);


if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
$change='<div class="msgdiv">Unknown Image extension </div> ';
$errors=1;
}
else
{
$size=filesize($_FILES['file']['tmp_name']);

if ($size > MAX_SIZE*1024)
{
$change='<div class="msgdiv">You have exceeded the size limit!</div> ';
$errors=1;
}

if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}

echo $scr;

list($width,$height)=getimagesize($uploadedfile);

$tmp=imagecreatetruecolor($newwidth,$newheight);

imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

$filename = $dir_path."/". $_FILES['file']['name'];

imagejpeg($tmp,$filename,100);

imagedestroy($src);
imagedestroy($tmp);

}
}

}

//If no errors registred, print the success message
 if(isset($_POST['Submit']) && !$errors)
 {
echo $message=' <div class="msgdiv">Image Uploaded Successfully!</div>';
 }
 else
 {
//echo $message = ' <div class="msgdiv">Image Not Uploaded...!</div>';
 }

?>

<!DOCTYPE HTML>
<html xml:lang="en"  lang="en">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="en-us" http-equiv="Content-Language">
    <title>Image Resize Demo</title>
 </head>
 <body>
<form method="post" action="" enctype="multipart/form-data" name="form1">
<table width="500" border="0" align="center" cellpadding="5" cellspacing="5">
<tr><Td style="height:25px">&nbsp;</Td></tr>
<tr>
<td width="150"><div align="right" class="titles">Picture : </div></td>
<td width="350" align="left">
<div align="left">
 <input size="25" name="file" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/>
</div>
</td>
</tr>

<tr>
<td width="150"><div align="right" class="titles"> Height: </div></td>
<td><input type="number" name="image_height" required> px</td>
</tr>

<tr>
<td width="150"><div align="right" class="titles"> Width: </div></td>
<td><input type="number" name="image_width" required> px</td>
</tr>

<tr>
<Td></Td>
<Td valign="top" height="35px">
<input type="submit" id="mybut" value=" Upload " name="Submit"/>
</Td>
</tr>

</table>
</form>
</body>
</html>

//image_resize_url.php

<?php
// UPLOAD Image Using Image Path/URL
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$url = trim($_POST["url"]);
$folder1 = "images/";
$folder2 = "thumb/";
svaenewimage($url,$folder1,$folder2);
}
function svaenewimage($url,$folder1,$folder2)
{
$file = fopen($url,"rb");
if($file)
{
$directory1 = $folder1; // Directory to upload files to.
$directory2 = $folder2; // Directory to upload files to.
$valid_exts = array("jpg","jpeg","gif","png"); // default image only extensions
$ext = end(explode(".",strtolower(basename($url))));
if(in_array($ext,$valid_exts))
{
$rand = rand(1000,9999);
$filename = $rand . basename($url);
$newfile = fopen($directory1 . $filename, "wb"); // creating new file on local server
if($newfile)
{
//Resize 
$newwidth1 = 200;
$newheight1 = 250;
$newwidth2 = 92;
$newheight2 = 128;

$src = $url;
$file_size = basename($url);
if($ext=="jpg" || $ext=="jpeg" )
{
$src = imagecreatefromjpeg($url);
}
else if($ext=="png")
{
$src = imagecreatefrompng($url);
}
else 
{
$src = imagecreatefromgif($url);
}
list($width,$height)= getimagesize($url);
$tmp1 = imagecreatetruecolor($newwidth1,$newheight1);
$tmp2 = imagecreatetruecolor($newwidth2,$newheight2);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$newheight2,$width,$height);
$filename1 = $directory1.$filename;
$filename2 = $directory2.$filename;
imagejpeg($tmp1,$filename1,100);
imagejpeg($tmp2,$filename2,100);
imagedestroy($src);
imagedestroy($tmp1);
imagedestroy($tmp2);
//resize end
echo "File uploaded successfully...!<br>";
//echo ''.$directory1.$filename.'<br>';
//echo ''.$directory2.$filename.'<br>';*/
}
else 
{
echo 'Could not establish new file ('.$directory.$filename.') on local server. Be sure to CHMOD your directory to 777.'; 
}
}
else 
echo 'Invalid file type. Please try another file.'; 
}
}
else
echo 'Could not locate the file: '.$url.''; 
}


?>

<form action="#" method="post">
<label for="url">Enter URL:</label>
<input type="text" name="url" size="100" required /> <input type="submit" name="submit" value="Submit" />
</form>

//image_resize_url_upload.php
<?php
// UPLOAD Image Using Image Path/URL
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$url = trim($_POST["url"]);
$folder1 = "images/";
$folder2 = "thumb/";
svaenewimage($url,$folder1,$folder2);
}
function svaenewimage($url,$folder1,$folder2)
{
$file = fopen($url,"rb");
if($file)
{
$directory1 = $folder1; // Directory to upload files to.
$directory2 = $folder2; // Directory to upload files to.
$valid_exts = array("jpg","jpeg","gif","png"); // default image only extensions
$ext = end(explode(".",strtolower(basename($url))));
if(in_array($ext,$valid_exts))
{
$rand = rand(1000,9999);
$filename = $rand . basename($url);
$newfile = fopen($directory1 . $filename, "wb"); // creating new file on local server
if($newfile)
{
//Resize 
$newwidth1 = 200;
$newheight1 = 250;
$newwidth2 = 92;
$newheight2 = 128;

$src = $url;
$file_size = basename($url);
if($ext=="jpg" || $ext=="jpeg" )
{
$src = imagecreatefromjpeg($url);
}
else if($ext=="png")
{
$src = imagecreatefrompng($url);
}
else 
{
$src = imagecreatefromgif($url);
}
list($width,$height)= getimagesize($url);
$tmp1 = imagecreatetruecolor($newwidth1,$newheight1);
$tmp2 = imagecreatetruecolor($newwidth2,$newheight2);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$newheight2,$width,$height);
$filename1 = $directory1.$filename;
$filename2 = $directory2.$filename;
imagejpeg($tmp1,$filename1,100);
imagejpeg($tmp2,$filename2,100);
imagedestroy($src);
imagedestroy($tmp1);
imagedestroy($tmp2);
//resize end
echo "File uploaded successfully...!<br>";
//echo ''.$directory1.$filename.'<br>';
//echo ''.$directory2.$filename.'<br>';*/
}
else 
{
echo 'Could not establish new file ('.$directory.$filename.') on local server. Be sure to CHMOD your directory to 777.'; 
}
}
else 
echo 'Invalid file type. Please try another file.'; 
}
}
else
echo 'Could not locate the file: '.$url.''; 
}


?>

<form action="#" method="post">
<table align="center" style="margin-top:50px;">
<tr>
<td><label for="url">Enter URL:</label></td>
<td>
<input type="text" name="url" size="50" required /> 
</td>
</tr>

<!--<tr>
<td><label for="url">Upload Image:</label></td>
<td>
<input size="25" name="file" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" />
</td>
</tr>-->
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>

 
</form>

Tuesday 18 August 2015

How to create Stored Procedures for Insert,Update,Delete,Login in PHP?




<?php
STEP - 1
#### Create Insert Data Store Procedure In PHP ##### First Create Table
# Table structure for table `users`
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
# Dumping data for table `users`
INSERT INTO `users` (`id`, `name`, `username`) VALUES
(1, 'Karan', 'Raj'),
(2, 'Ram', 'Kishan'),
(3, 'Abc', 'Pqr');
#### Insert Record Procedure ####

STEP - 2
# This Run in PHPMyAdmin -> [database name] -> SQL
DELIMITER $$
DROP PROCEDURE IF EXISTS InsertUser $$
CREATE PROCEDURE InsertUser(IN  p_id INT(11),IN  p_name VARCHAR(50),IN  p_username VARCHAR(50))
BEGIN
    INSERT
  INTO
   users(id,name,username)
  VALUES
   (p_id,p_name,p_username);
END $$
DELIMITER ;

STEP - 3
$host="localhost";
$username="root";
$password="";
$dbname="test";

$con = new PDO("mysql:host=$host;dbname=$dbname",$username,$password) or die(mysql_error());

if($_SERVER["REQUEST_METHOD"] == "POST"){
  if($_POST['insert_data'] == "Submit") {
    try {
      $conn = new PDO("mysql:host=localhost;dbname=test",'root','');

      // execute the stored procedure
      $id=''; 
      $name=ucfirst($_POST['name']);
      $username=ucfirst($_POST['username']);

      $sql = "CALL InsertUser('','$name','$username')";
      $q = $conn->query($sql);
      echo "insert Suucess...!";    
    } catch (PDOException $pe) {
      die("Error occurred:" . $pe->getMessage());
    }
  }
}
?>
<html>
<title>How to create Stored Procedures for Insert,Update,Delete,Login in PHP?</title>
<div align="center">
<form action="<?php basename($_SERVER['PHP_SELF']); ?>" method="POST">
  <table>
    <tr><td>Name : </td><td><input type="text" name="name" required="required" /></td></tr>
    <tr><td>Username : </td><td><input type="text" name="username" required="required"/></td></tr>
    <tr><td colspan="2"><input type="submit" name="insert_data" value="Submit"/></td></tr>
  </table>
</form>
</div>
</html>