Enter Keyword Hear for Search This Blog

Saturday, 23 April 2016

String function in php

echo

<?php
echo " A value is ";
$a=4;
echo $a;
?>


chr

<?php
echo chr(65);
echo "<br/>";
echo chr(122);
?>


strlen

<?php
$pwd="abc@123";
if(strlen($pwd)<6)
{
echo "password to short";
}
?>


ord

<?php
echo ord(' ');
echo "<br/>";
echo ord('z');
?>

print

<?php
print " A value is ";
$a=4;
print $a;
?>

strtoupper

<?php
echo strtoupper('hello');
echo "<br/>";
echo strtoupper('world');
?>

strtolower

<?php
echo strtolower('HEllo');
echo "<br/>";
echo strtolower('WORLD');
?>


substr

<?php
$a="harsukh k k";
$b=strlen($a);
for($i=0;$i<=9;$i++){
$j=substr($a,$i,1);
$d=ord($j);
echo $d;
echo"<br />";
echo $j;
}


?>

chop

<?php
     $str = "Hello World!";
     echo $str . "<br>";
     echo chop($str,"World!");
?>

join

<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>

parse_str

<?php
parse_str("name=Peter&age=43");
echo $name."<br>";
echo $age;
?>

How to create pagging system using php

view_pagging.php

<?php

$link=mysql_connect("localhost","root","");

mysql_select_db("product",$link);

$page_q="select * from mobile";

$page_res=mysql_query($page_q,$link); 

$item=3;
$total_record=mysql_num_rows($page_res);
$total_page=ceil($total_record/$item);
$cur_page=(isset($_GET['page']))?$_GET['page']:1;
?>
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
</tr>

<?php

$k=($cur_page-1)*$item;

$q="select * from mobile LIMIT $k,$item";

$res=mysql_query($q,$link);

while($row=mysql_fetch_array($res))
{
echo '<tr align="center">
<td>'.$row['id'].'
<td>'.$row['nm'].'
</tr>';
}
?>
</table>

<center>
<?php
if($cur_page>1)
{
echo '<a href="view_pagging.php?page='.($cur_page-1).'">Previous </a>';
}
else
{
echo 'Previous';
}

for($i=1;$i<=$total_page;$i++)
{
echo '<a href="view_pagging.php?page='.$i.'">'.$i.'</a> ';
}

if($cur_page<$total_page)
{
echo '<a href="view_pagging.php?page='.($cur_page+1).'">Next</a>';
}
else{
echo 'Next';
}
?>
</center>
</body>
</html>

How to create login logout system using php

login.php

      <html>
<head>
</head>

<body>
<form action="login_pro.php" method="post">
      username<br />
     <input type="text" name="unm">
     <br />
     <br />
     password<br />
     <input type="password" name="pwd">
     <br />
     <br />
     <input type="submit" value="login">
                      </form>
</body>
      </html>


login_pro.php

<?php session_start();
if (empty($_REQUEST['unm']) || empty($_REQUEST['pwd']))
{
echo "pleace enter username and password";
}
else
{
$link=mysql_connect("localhost","root","");
mysql_select_db("login",$link);
$unm=$_REQUEST['unm'];
$pwd=$_REQUEST['pwd'];

$q="select * from registration where unm='$unm' and pwd='$pwd'";

$res=mysql_query($q,$link)or die($row);
$row=mysql_fetch_array($res);

if(empty($row))
{
echo"wrong username or password";
}
else
{
$_SESSION['unm']=$row['unm'];
$_SESSION['status']=true;
header("location:index1.php");
}
}
?>

index1.php

<?php session_start();
if(isset($_SESSION['status']))
{
echo 'hello:'.$_SESSION['unm'];
echo '<a href="logout.php">Logout</a>';
}
else
{
header("location:logout.php");
}
?>

logout.php

<?php session_start();
 session_destroy();

header("location:login.php");
?>

How to insert,delete and select data from database using php

insert.php

<html>
<body>
<form action="insert_pro.php" method="post">
Name :<br />
<input type="text" name="nm" />
<br /><br />

Salary :<br />
<input type="text" name="sal" />
<br /><br />

<input type="submit" value="Insert">
</form>
</body>
</html>

insert_pro.php

<?php
$nm=$_POST['nm'];
$sal=$_POST['sal'];

$link=mysql_connect("localhost","root","") or die("can't connect");

mysql_select_db("employee",$link) or die("Wrong Database");

$q="insert into emp
(nm,salary)
values('$nm',$sal)";

mysql_query($q,$link) or die($q);

header("location:view.php");
?>

view.php

<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
<th>Salary</th>
<th>Delete</th>
</tr>

<?php

$link=mysql_connect("localhost","root","");

mysql_select_db("employee",$link);

$q="select * from emp";

$res=mysql_query($q,$link);

while($row=mysql_fetch_array($res))
{
echo '<tr align="center">';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['nm'].'</td>';
echo '<td>'.$row['salary'].'</td>';
echo '<td><a href="delete_pro.php?no='.$row['id'].'">X</a></td>';
echo '</tr>';
}
?>
</table>
</body>
</html>

delete_pro.php

<?php
$id=$_GET['no'];

$link=mysql_connect("localhost","root","");

mysql_select_db("employee",$link);

$q="delete from emp where id=$id";

mysql_query($q,$link);

header("location:view.php");
?>

How to play video using html tag

video.html

<html>
<head>
</head>
<body>
<video controls>
<source src="aadat.mkv" type="video/mp4" height="500" width="500">
</video>

<video controls>
<source src="Axwell_-_Feel_the_Vibe[MINS00000880].mkv" type="video/mp4" >
</video>

<video controls>
<source src="Billo Rani.mkv" type="video/mp4" >
</video>
</body>
</html>

How to play song using html tag

song.html


<html>
<body>

<audio controls>
<source src="1.mp3" type="audio/mpeg" name="1">
</audio>
<hr size="10px" color="green"/>
<audio controls>
<source src="01.mp3" type="audio/mpeg" name="2">
</audio>

</body>
</html>

how to only image upload in database using php

form.php

<html>
<body>
<form action="form_pro.php"method="post"enctype="multipart/form-data">
<h1>Image:</h1>
<input type="file"name="img"/>
<br/><br/>
<input type="submit"value="upload"/>
</form>
</body>
</html>

form_pro.php

<?php
if(empty($_FILES['img']['name']))
{
echo "Please select image";
}
else
{
$ext=strtolower(substr($_FILES['img']['name'],-4));
if(!($ext==".jpg" || $ext=="jpeg" || $ext==".png" || $ext==".gif"))
{
echo "Wrong File";
}
else

{
$fname=time().$_FILES['img']['name'];
$fname=str_replace(" ","_",$fname);
move_uploaded_file($_FILES['img']['tmp_name'],"cbr/".$_FILES['img']['name']);
{
echo "Image Selected";
}
}
}
?>

captcha code with background image

captcha.php


<?php
$a="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$str="";

for($i=1;$i<=6;$i++)
{
       $str=$str.substr($a,rand(0,strlen($a)-1),1);
}

$img=imagecreate(200,100);
imagecolorallocate($img,200,100,100);
imagettftext($img,20,0,20,70,8,"RAVIE.TTF",$str);
header("content-type:image/jpeg");
imagejpeg($img);
?>

How to upload image and image name in database using php

form.php

<?php session_start(); ?>

<form action="form_pro.php" method="post" enctype="multipart/form-data" style="font-size:10px;">
                                <?php 
                                    if (isset($_SESSION['o_e']['iname'])) 
                                    {
                                        echo '<span class="alert alert-danger">'.$_SESSION['o_e']['iname'].'</span>';
                                    } 
                                    if (isset($_SESSION['o_e']['req']))
                                    {
                                        echo '<span class="alert alert-danger">'.$_SESSION['o_e']['req'].'</span>';
                                    }
                                    if (isset($_SESSION['o_e']['wro']))
                                    {
                                        echo '<span class="alert alert-danger">'.$_SESSION['o_e']['wro'].'</span>';
                                    }
                                    if (isset($_SESSION['o_e']['up']))
                                    {
                                        echo '<span class="alert alert-success">'.$_SESSION['o_e']['up'].'</span>';
                                    }
                                    unset($_SESSION['o_e']);
                                ?>
                                <input type="file" name="o_img" class="form-control">
                                <br/>
                                <input type="text" name="i_nm" class="form-control" placeholder="Enter Image Name"/>
                                <br/>
                            
                                <input type="submit" value="    Upload    " class="btn btn-success">
</form>



form_pro.php


<?php  session_start();

$_SESSION['o_e']=array();
extract($_POST);
if (empty($_POST['i_nm']))
{
$_SESSION['o_e']['iname']="Enter Image Name";
header('location:form_pro.php');
}

if (!empty($_SESSION['o_e']))
{
header('location:form_pro.php');
}
else
{
if (empty($_FILES['o_img']['name']))
{
$_SESSION['o_e']['req']="First Fill all Details";
header('location:form_pro.php');
}
else
{
$ext=strtolower(substr($_FILES['o_img']['name'],-4));
if(!($ext==".jpg" || $ext==".jpe" || $ext=="jpeg" || $ext==".png" || $ext==".bmp" || $ext==".gif"))
{
$_SESSION['o_e']['wro']="Wrong File Selected";
header('location:form_pro.php');
}
else
{
$iname=time().$_FILES['o_img']['name'];
$iname=str_replace(" ","_", $iname);
move_uploaded_file($_FILES['o_img']['tmp_name'],"image/gallary/".$iname);


extract($_POST);

$link=mysql_connect('localhost','root','');

mysql_select_db('song_admin',$link);

$query="insert into header_image 
(iname,i_nm) 
values 
('$iname','$i_nm')";

mysql_query($query,$link);

$_SESSION['o_e']['up']="Image is Uploading";

header('location:form_pro.php');
}
}
}

?>

Thursday, 31 March 2016

How to check number prime or not in java

primeno.java

class primeno
{
public static void main(String args[])
{
int no=17,flag=0;
int m=no/2;

for(int i=2;i<=m;i++)
{
if(no%i==0)
{
System.out.println("This Number is not Prime");
flag=1;
break;
}

}
if(flag==0)
{
System.out.println("This number is Prime");
}
}
}

Tuesday, 29 March 2016

How to drag and drop between two textbox

twobox.html



<html>
    <head>
        <title>Drag And Drop between two textbox</title>
        <script type="text/javascript">
            function handleDragDropEvent(oEvent) {
                var oTextbox = document.getElementById("txtara");
                oTextbox.value =oTextbox.value + oEvent.type + "\n";
            }
        </script>
    </head>
    <body>
        <P>Dragging the text from the left textbox to the right textbox.</p>
        <P>
        <input type="text" value="drag this text"/>
        <input type="text"
               ondragenter="handleDragDropEvent(event)"
               ondragover="handleDragDropEvent(event)"
                             />
        </p>
        <P><textarea rows="12" cols="23" readonly="readonly" id="txtara"></textarea></p>
    </body>
</html>

How to show drag and drop event in textarea using event.type in javascript

dragdrop1.html



<html>
    <head>
        <title>Show Event Drag And Drop</title>
        <script type="text/javascript">
            function handleDragDropEvent(oEvent)
            {
                var oTextbox = document.getElementById("txtara");
                oTextbox.value = oTextbox.value + oEvent.type + "\n";
            }
        </script>
    </head>
    <body>
        <P>This is a text</p>
        <input type="text"
               ondragenter="handleDragDropEvent(event)"
               ondragover="handleDragDropEvent(event)"
               /></p>

        <P><textarea rows="12" cols="23"  id="txtara"></textarea></p>
    </body>
</html>

Monday, 7 March 2016

How to download direct any file using php code

download.php

<?php

$getfile="https://www.demo.com/bollywood/videos/2.mp4";

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$getfile);
header('Content-Transfer-Encoding: binary');

$file = @ fopen($getfile, 'rb') or die("Techincal Error");    

fpassthru($file);
        
?>

Friday, 4 March 2016

How to create a clock window using moveBy in JavaScript

clock.html


<html>
<head><title> MoveBy</title>
</head>
<script>
var x=0;
var y=0;
function openwin()
{
mywin=window.open("","","width=50,height=50");
}
function closewin()
{
if(mywin)
{
mywin.close();
}
}

function movebywin()
{
if(x<600 && y==0)
{
x=x+200;
if(x==600)
{
y=y+100;
}
}
else if(x==600 && y<=300)
{
y=y+100;
if(y==300)
{
x=x-200;
}
}
else if( x<=600 && y==300)
{
x=x-200;
if(x==0)
{
y=y-100;
}
}
else if(x==0 && y<=300)
{
y=y-100;
if(y==0)
{
x=x+200;
}
}
mywin.moveTo(x,y);
mywin.focus();
}
</script>
<body>
<input type="button" value="Open window" onclick="openwin()">
<input type="button" value="Move" onclick="movebywin()">
<input type="button" value="Close" onclick="closewin()">
</body>
</html>

How to create window clock using move in JavaScript

clock.html


<html>
<head><title> MoveBy</title>
</head>
<script>
var x=0;
var y=0;
function openwin()
{
mywin=window.open("","","width=10,height=10");
}
function closewin()
{
if(mywin)
{
mywin.close();
}
}

function movebywin()
{
if(x<600 && y==0)
{
x=x+200;
if(x==600)
{
y=y+100;
}
}
else if(x==600 && y<=300)
{
y=y+100;
if(y==300)
{
x=x-200;
}
}
else if( x<=600 && y==300)
{
x=x-200;
if(x==0)
{
y=y-100;
}
}
else if(x==0 && y<=300)
{
y=y-100;
if(y==0)
{
x=x+200;
}
}
mywin.moveTo(x,y);
mywin.focus();
}
</script>
<body>
<input type="button" value="Open window" onclick="openwin()">
<input type="button" value="Move" onclick="movebywin()">
<input type="button" value="Close" onclick="closewin()">
</body>
</html>

Thursday, 25 February 2016

How to create clock wise window screen in javascript

clock.html


<html>
<head><title> MoveBy</title>
</head>
<script>
var x=0;
var y=0;
function openwin()
{
mywin=window.open("","","width=10,height=10");
}
function closewin()
{
if(mywin)
{
mywin.close();
}
}

function movebywin()
{
if(x<600 && y==0)
{
x=x+200;
if(x==600)
{
y=y+100;
}
}
else if(x==600 && y<=300)
{
y=y+100;
if(y==300)
{
x=x-200;
}
}
else if( x<=600 && y==300)
{
x=x-200;
if(x==0)
{
y=y-100;
}
}
else if(x==0 && y<=300)
{
y=y-100;
if(y==0)
{
x=x+200;
}
}
mywin.moveTo(x,y);
mywin.focus();
}
</script>
<body>
<input type="button" value="Open window" onclick="openwin()">
<input type="button" value="Move" onclick="movebywin()">
<input type="button" value="Close" onclick="closewin()">
</body>
</html>

Tuesday, 23 February 2016

How to create JavaScript simple program

1.html 


<script type="text/javascript" language="javascript">

      var num=3;

      switch (num)
     {
                    case 1: alert("One");
                                  break;
                    case 2: alert("Two");
                                  break;
                    case 3: alert("Three");
                                  break;
                    case 4: alert("Four");
                                  break;
                    case 5: alert("Five");
                                  break;
                       
                   default: alert("Select 1 to 5 Number");
     }       
</script>


                                Array


=>Def : Array is a collection of data
1. length

<script>
     var cars = ["Saab", "Volvo", "BMW"];
    cars.length;
</script>


2.Element

<div id="ele"> </div>

<script>
          var bike=["R15","Shine","Honda","Bajaj"];
          document.getElementById("ele").innerHTML=bike;
</script>

Method : 1.push()
                 2.pop()
                 3.shift()
                 4.unshift()
                 5.concat()
                 3.join()


Properties : 1.length()
                     2.prototype()
                     3.constructor()
               

=> Array in array
  
<script>
             var demo = new array();
                      demo[0] = new array();
                      demo[0][0]='A0';
                      demo[0][1]='B0';
                      demo[0][2]='C0';

                      demo[1] = new array();
                      demo[1][0]='A1';
                      demo[1][1]='B1';
                      demo[1][2]='C1';

                      demo[2] = new array();
                      demo[2][0]='A2';
                      demo[2][1]='B2';
                      demo[2][2]='C2';
       
                      document.write("A : "+demo[0][0]+"<br/>");
                      document.write("B : "+demo[0][1]+"<br/>");
</script>

Friday, 19 February 2016

How to create a simple form in html

form.html


<form action="form.html" method="post" enctype="multipart-form">
       <input type="file" name="logo" required>
       <br/><br/>
       <input type="text" name="fnm" placeholder="Enter First Name" required>
       <br/><br/>
       <input type="text" name="lnm" placeholder="Enter Last Name" required>
       <br/><br/>
       <input type="text" name="unm" placeholder="Enter User Name" required>
       <br/><br/>
       <input type="email" name="email" placeholder="Enter Email-Id" required>
       <br/><br/>
       <input type="password" name="pwd" placeholder="Enter Password" required>
       <br/><br/>
       <input type="password" name="rpwd" placeholder="Enter Re-Password" required>
       <br/><br/>

       <input type="submit" value="Submit">
</form>

Monday, 15 February 2016

Select Query in php

  1.  How to compare your email and pwd with your database in login table
       - select * from login where email="$email" and pwd="$pwd"
       - select email,pwd from login where email="$email" and pwd="$pwd" 

     2.  How to select table in column
      
       - select * from table_name
       - select col1,col2 from table_name

     3. How to used select query with order by,limit and ascending order
     
      - select * from table1 order by 'table1','col1' ASC 

      - select * from table1 order by 'table1','col1' DESC

      - select * from table1 order by 'table1','col1' ASC LIMIT 0,30

How to create a Captcha code in php


ex1.php


<?php 

    $a = "abcdefghijklmnopqrstuvwxyz0123456789                ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    $str = " ";

    for ($i=1; $i <=6 ; $i++)
    { 
$str = $str.substr($a, rand(0,strlen($a)-1),1);
    }

echo $str;

?>


Featured post

what is ajax?how to create ajax with php code

Ajax Introduction -  એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો...