Enter Keyword Hear for Search This Blog

Tuesday, 11 October 2016

what is ajax?how to create ajax with php code

Ajax Introduction

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

- अजाक्स का उपियोग करके आप कोई भी डाटा स्पीड में ले सकते हे और इसकी प्रोसेस प्रोसेसबार में नहीं दिखती अजाक्स अपने डाटा सर्वर को सेंड करते समय सेकुएंस मेन्टेन नहीं करता इस लिए हम डाटा फ़ास्ट एक्सेस कर सकते हे

- Ajax stands for Asynchronous JavaScript and XML. Ajax isn’t a technology; it mixes well-known programming techniques in an uncommon way to enable web developers to build Internet applications with much more appealing user interfaces.

The parts of an Ajax application that happen "under the hood" of the browser, such as sending server queries and dealing with the returned data, are written in JavaScript, and XML is a means of coding and transferring formatted information used by Ajax to efficiently transfer data between server and client.

-  You cannot make use of the XMLHTTPRequest until you have created an instance of it.

-Microsoft first introduced the XMLHTTPRequest object, implementing it in Internet Explorer 5 as an ActiveX object. 


- The following line creates an XMLHTTPRequest object called request

               var request = new XMLHTTPRequest(); 
-  Here we have declared a variable request and assigned to it the value returned from the statement
new XMLHTTPRequest(),which is invoking the constructor method for the XMLHTTPRequest object.
-  To achieve the equivalent result in Microsoft Internet Explorer, you need to create an ActiveX object.
 Here's an example
               var request = new ActiveXObject("Microsoft.XMLHTTP");
- This assigns the name request to the new object.
-  Some versions of Internet Explorer have a different version of MSXML, the Microsoft XML parser, 
installed in those cases you need to use the following instruction
               var request = new ActiveXObject("Msxml2.XMLHTTP");
- For cross Browser detection, this is the following code :

function ajaxFunction()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
      // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
      alert("Your browser does not support XMLHTTP!");
    }
}

In above example create a variable named xmlhttp to hold the XMLHttpRequest object,
Try to create the XMLHttpRequest object with xmlhttp=new XMLHttpRequest(). If that fails, 
try xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"). 
This is for IE6 and IE5. If that fails too, the user has a very outdated browser, 
and will get an alert stating that the browser doesn't support XMLHTTP.

Note: The code above can be used every time you need to create an XMLHttpRequest object.
-  XMLHTTPRequest class is predefined in php
-  Ajax have a some method and properties
Method : open, send
Properties :onreadystatechangereadyState, responseText and status 

Ajax With Html demo.html

ajaxdemo.html

<script type="text/javascript">
var http = false;
if(navigator.appName == "Microsoft Internet Explorer")
{
                        http = new ActiveXObject("Microsoft.XMLHTTP");
} else
{
  http = new XMLHttpRequest();
}
function replace()
{
  http.open("GET", "test.txt", true);
  http.onreadystatechange=function()
 {
    if(http.readyState == 4)
   {
      document.getElementById('changed').innerHTML = http.responseText;
    }
 }
  http.send(null);
}
</script>
<p><a href="javascript:replace()">Replace Text</a></p>

<div id="changed">
            Hello, world!
</div>

test.txt
This is the content of test.txt

Sunday, 2 October 2016

how to use css in your website

Basic Introduction related CSS


how create template using html5 tags



- यह पोस्ट में आप HTML5 के टैग का उपयोग करके बहुत सरलता से अपनी डिजाईन और फॉर्म बना सकते हे.
- In this post you very simply by using HTML5 tags, create your own design and form.
- આ પોસ્ટ માં તમે HTML5 નો ઉપયોગ કરી ખુબજ સરળતા થી તમારી પોતાની Design અને ફોર્મ(Form) બનાવી શકો છો.

Monday, 2 May 2016

How to create Regular expression validation in php

index.php

<?php session_start(); ?>
<html>
<head>
<title>Registration</title>
</head>
<body>
<?php
if(isset($_SESSION['vali']['ok']))
{
echo '<span style="color:green;">'.$_SESSION['vali']['ok'].'</span>';
}
?>
<form action="process.php" method="post" enctype="multipart/form-data">
FullName : <br/>
<input type="text" name="fnm">
<?php 
if(isset($_SESSION['vali']['fnm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['fnm'].'</span>';
}
?>
<br/><br/>

UserName : <br/>
<input type="text" name="unm">
<?php 
if(isset($_SESSION['vali']['unm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['unm'].'</span>';
}
?>
<br/><br/>
Password : <br/>
<input type="password" name="pwd">
<?php 
if(isset($_SESSION['vali']['pwd']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['pwd'].'</span>';
}
?>
<br/><br/>
Conform Password : <br/>
<input type="password" name="cpwd">
<?php
if(isset($_SESSION['vali']['cpwd']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['cpwd'].'</span>';
}
if(isset($_SESSION['vali']['pwdm']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['pwdm'].'</span>';
}
?>
<br/><br/>
Mobile No : <br/>
<input type="text" name="mno">
<?php 
if(isset($_SESSION['vali']['mno']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['mno'].'</span>';
}
if(isset($_SESSION['vali']['digits']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['digits'].'</span>';
}
if(isset($_SESSION['vali']['max']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['max'].'</span>';
}
?>
<br/><br/>

Email Id : <br/>
<input type="text" name="email">
<?php 
if(isset($_SESSION['vali']['email']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['email'].'</span>';
}
if(isset($_SESSION['vali']['regex']))
{
echo '<span style="color:red;">'.$_SESSION['vali']['regex'].'</span>';
}
unset($_SESSION['vali']);
?>
<br/><br/>
<input type="submit" value="Submit">

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


process.php

<?php  session_start();
$_SESSION['vali']=array();
extract($_POST);

if(empty($_POST['fnm']))
{
$_SESSION['vali']['fnm']="Enter Fullname";
}
if(empty($_POST['unm']))
{
$_SESSION['vali']['unm']="Enter Username";
}
if(empty($_POST['pwd']))
{
$_SESSION['vali']['pwd']="Enter Password";
}
if(empty($_POST['cpwd']))
{
$_SESSION['vali']['cpwd']="Enter Re-Password";
}
if($_POST['pwd'] != $_POST['cpwd'])
{
$_SESSION['vali']['pwdm']="Do not match password";
}
if(empty($mno))
{
$_SESSION['vali']['mno']="Enter Mobile No";
}
else if(!is_numeric($mno))
{
$_SESSION['vali']['digits']="Enter Digits";
}
else if(strlen($_POST['mno'])<10)
{
$_SESSION['vali']['max']="Enter 10 Digits";
}
if(empty($_POST['email']))
{
$_SESSION['vali']['email']="Enter Email Id";
}
if(! ereg("^[a-z0-9_]+[a-z0-9_.]*@[a-z0-9_-]+[a-z0-9.-]*\.[a-z]{2,5}$",$_POST['email']))
{
$_SESSION['vali']['regex']="Email not valid";
}
if(!empty($_SESSION['vali']))
{
header('location:index.php');
}
else
{

extract($_POST);

$link=mysql_connect('localhost','root','')or die("connect problem");
mysql_select_db('test',$link);
$q="insert into register(fnm,unm,pwd,mno,email)values('$fnm','$unm','$pwd','$mno','$email')";
mysql_query($q);
$_SESSION['vali']['ok']="Record Insrted";
header('location:index.php');

}
?>

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>

Featured post

what is ajax?how to create ajax with php code

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