Tuesday, 25 August 2015

php-pear-mai-tutorial

(1)first download  pear package to send email  following link is given:

https://pear.php.net/package/PEAR/download


& find Mail.php  file

(2)find code for sending email with  smtp setting details  save this file name by email.php  under same  folder where Mail.php file is stored run it :


<?php

require_once "Mail.php";

    $from = "youremailid@gmail.com";
 
    $to = "omchandmaurya1@gmail.com";
 
    $subject = "Hi!";
 
    $body = "Hi,\n\nHow are you?";
 

    $host = "ssl://smtp.gmail.com";
 
    $port = "465";
 
    $username = "youremailid@gmail.com";
 
    $password = "yourpassword";
 

    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password));

    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
    } else {
      echo("<p>Message successfully sent!</p>");
    }


?>


Php   Mail   function :
<?php

   $to = "omchandmaurya1@gmail.com";
  
 
   $subject = "This is subject";
  
 
   $message = "This is simple text message.";
  
 
   $header = "From:omnetworkom@gmail.com \r\n";
  
 
   $retval = mail ($to,$subject,$message,$header);
  
 
   if( $retval == true ) 
 

   {

      echo "Message sent successfully...";

   }

   else

   {

      echo "Message could not be sent...";

   }

?>


Sending email using Php-Mail-function

The mail() function allows you to send emails directly from a script.

Syntax:


mail(to,subject,message,headers,parameters);

to    =>  Required. Specifies the receiver / receivers of the email
subject =>  Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters
message  =>    Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters.

headers  =>  Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n).
Note: When sending an email, it must contain a From header. This can be set with this parameter or in the php.ini file.

parameters  =>  Optional. Specifies an additional parameter to the sendmail program (the one defined in the sendmail_path configuration setting). (i.e. this can be used to set the envelope sender address when using sendmail with the -f sendmail option)


See below example  :

<?php

   $to = "om@gmail.com";
  
 
   $subject = "This is subject";
  
 
   $message = "This is simple text message.";
  
 
   $header = "From:omnetworkom@gmail.com \r\n";
  
 
   $retval = mail ($to,$subject,$message,$header);
  
 
   if( $retval == true ) 
 

   {

      echo "Message sent successfully...";

   }

   else

   {

      echo "Message could not be sent...";

   }

?>


========================================================================
contact form code to send email using Mail() function  :

(1)write code for  contactform.html :

<h2>Send us your Complain<em><em></h2>
<h3>
<form action=sendmail.php  method=post>
Name:<input id="name" name="name" type="text"   placeholder="Enter your Name"  class="required"><br><br>


EMAIL:<input id="email" name="email" type="text"       placeholder="Enter your Email id"   class="required"><br><br>


PHONE:<input id="phone"    name="phone"     type="text"  placeholder="Enter your Phone"   class="required" ><br><br>


Message:<textarea  rows=5  cols=30  id="message"      class="required">Enter your Query & Message </textarea><br></br>

<input name="myBtn" type="submit" value="Submit Data"    > <br><br>

<div id="status"></div>
                    </form>
                  </div>


(2)write code for  sendmail.php  file:

<?php

$to="om@gmail.com";

$subject="Complain & Enquiry from users";

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$message=$_POST['message'];

$msg="Name:$name/Email:$email/Phone:$phone/Message:$message";

$mail=mail($to,$subject,$msg);

if($mail)

{


echo "mail sent succssfully";

}
else
{
echo "mail not sent successfully";

}

?>

========================================================================
contact form code with Ajax to send email using Mail() function:

step 1: write code for  contactus.html    file : 

<!DOCTYPE html>
<html lang="en">
<head>
<script>
function ajax_post(){
    // Create our XMLHttpRequest object
    var hr = new XMLHttpRequest();
    // Create some variables we need to send to our PHP file
    var url = "sendmail.php";
    var fn = document.getElementById("name").value;

    var en = document.getElementById("email").value;

var pn = document.getElementById("phone").value;

var pd = document.getElementById("message").value;



    var vars = "name="+fn+"&email="+en+"&phone="+pn+"&message="+pd;

    hr.open("POST", url, true);
    // Set content type header information for sending url encoded variables in the request
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    // Access the onreadystatechange event for the XMLHttpRequest object
    hr.onreadystatechange = function() {
   if(hr.readyState == 4 && hr.status == 200) {
   var return_data = hr.responseText;
document.getElementById("status").innerHTML = return_data;
   }
    }
    // Send the data to PHP now... and wait for response to update the status div
    hr.send(vars); // Actually execute the request
    document.getElementById("status").innerHTML = "processing...";
}
</script>

 </head>

<body>

<h2>Send us your Complain<em><em></h2>
<h3>
Name:<input id="name" name="name" type="text"   placeholder="Enter your Name"  class="required"><br><br>


EMAIL:<input id="email" name="email" type="text"       placeholder="Enter your Email id"   class="required"><br><br>


PHONE:<input id="phone"    name="phone"     type="text"  placeholder="Enter your Phone"   class="required" ><br><br>


Message:<textarea  rows=5  cols=30  id="message"      class="required">Enter your Query & Message </textarea><br></br>

<input name="myBtn" type="submit" value="Submit Data" onclick="ajax_post();"> <br><br>

<div id="status"></div>
                    </form>
                  </div>
             
</body>
</html>

step 2:   write code for   sendmail.php  file  :

<?php

$to="om@gmail.com";

$subject="Complain & Enquiry from users";

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$message=$_POST['message'];

$msg="Name:$name/Email:$email/Phone:$phone/Message:$message";

$mail=mail($to,$subject,$msg);

if($mail)

{


echo "mail sent succssfully";

}
else
{
echo "mail not sent successfully";

}

?>



Monday, 24 August 2015

how -to -build- a simple WordPress- theme in four simple steps:


 Step 1 :

In the WordPress /themes/ directory, create a folder named /simplest-theme/

Step 2:

 In the new directory, create two new (empty) files, style.css and index.php

 Step 3 :

Open style.css and add the following code:

 /* Theme Name: Simplest Theme */


Step 4 :

 Open index.php and add paste the code given  below :

<!DOCTYPE html>
<html>
 <head>
 <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
 <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
 </head>
 <body>
 <header>
 <h1><a href="<?php echo home_url('/'); ?>">
 <?php bloginfo('name'); ?></a>
 </h1>
 <p><?php bloginfo('description'); ?></p>
 </header>
 <article>
 <?php if (have_posts()) : ?>
 <?php while (have_posts()) : the_post(); ?>
 <div class="post">
 <h2><a href="<?php the_permalink(); ?>">
 <?php the_title(); ?></a>
 </h2>
 <?php the_content(); ?>
 </div>
 <?php endwhile; ?>
 <div class="post-nav">
 <?php posts_nav_link(); ?>
 </div>
 <?php endif; ?>
 </article>
 <footer>
 <p>&copy; <?php echo date('Y'); bloginfo('name'); ?></p>
 </footer>
 </body>

</html>

Congratulations you have built a simple wordpress theme..

For loop practice code for star pattern & number pattern

Consider output:


1
1 1
1 1 1

Code for  given output:


<?php
$n=4;
for($i=0;$i<$n;$i++)
{

for($j=0;$j<$i;$j++)
{
 echo " 1";
}

echo "<br>";
}

?>


Nesting looping concept  step by step  :

step 1: 
i=0  0<4   true
j=0  0<=0  true
print 1
j++
repeat j loop  
now j=1
1<=0  false
hence print 
 new line

 step 2:
 i=1  1<4  true
 j=0   0 <=1  true
 print 1
 j++
 repeat j loop
 now j=1

 1<=1  true
 print 1
 j++
 repeat j loop 
 now j=2
 2<=1 false
 new line

 step 3:
 i=2  2<4  true
 j=0  0<=1  true
 print 1
 j++
 repeat j loop  
 now j=1
 1<=2  true
 print 1
 j++
 repeat j loop
 now j=2
 2<=2  true
 print 1
 j++ 
 repeat j loop
 now j=3
 3<=2  false
 new line


============================================================= 



(1)

<?php

for($i=0;$i<=5;$i++)
{

for($j=1;$j<=$i;$j++)
{

echo "*"."&nbsp;";

}
echo "<br>";
}
?>

Output:

*
* *
* * *
* * * *
* * * * * 


(2)
<?php

for($i=0;$i<=5;$i++)
{

for($j=1;$j<=$i;$j++)
{

echo $j."&nbsp;";

}
echo "<br>";
}
?>

Output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5 


(3)
<?php
$a=1;
$k=5;

for($i=1; $i<=$k; $i++){

for($j=1;$j<=$i;$j++){

echo $a;
$a++;
}

print("<br/>");
}
?>
Output:

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Displaying data from table using for loop example :

(1)create table book with  columns  id,name,address & insert some values:

save given below file as "display.php" :

<?php

$con=mysql_connect("localhost","root","");             //connection

mysql_select_db("amrapali",$con);                    //database selection
$sql="select * from book";                       //query 
$result=mysql_query($sql);                    //execute query
$num=mysql_num_rows($result);                //count record from table

for($i=0;$i<$num;$i++)

{

$row=mysql_fetch_array($result);              //fetching records from  $result

echo $row['id'];

echo $row['name'];

echo $row['address'];

echo'<br>';

}


?>

Thursday, 20 August 2015

MYSQLi introduction with insert,update,delete,select

Mysqli :
“mysqli”  extension is an improvement over the old  “mysql” extension. In fact, the “i” in  mysqli  stands for “improved”.
mysqli  was developed to take advantage of the new features available in  MySQL since version 4.1.3. Also, you can use it since PHP 5. So, if you code with PHP5 with a newer version of MySQL,  it’s strongly recommended for you to use the extension “mysqli” over  “mysql”.

Example for inserting record into  MYGuests  Table:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";

if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
?>

Example for displaying record from table:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
    }
}
else
{
    echo  "0 results";
}

 mysqli_close($conn);

?>

Example    for     update      Table:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";

if (mysqli_query($conn, $sql)) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . mysqli_error($conn);
}

mysqli_close($conn);
?>







Example    for    Delete    Table:

<?php

$servername = "localhost";

$username = "username";

$password = "password";

$dbname = "myDB";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// sql to delete a record
$sql = "DELETE FROM MyGuests WHERE id=3";

if (mysqli_query($conn, $sql)) {
    echo "Record deleted successfully";
} else {
    echo "Error deleting record: " . mysqli_error($conn);
}

mysqli_close($conn);
?>








Wednesday, 19 August 2015

Insert-Multiple-Records-Into-MySQL-Using-MySQLi


CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50));

(2)see  following Code  “multi.php”:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "batch";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com');";
$sql .= "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Mary', 'Moe', 'mary@example.com');";
$sql .= "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Julie', 'Dooley', 'julie@example.com')";

if ($conn->multi_query($sql) === TRUE) {
    echo "New records created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

















html,css guidance for developing a very simple home page...

First of all understand  Layout of given  below :

(1)main  class which contains all  other header,container,footer 
(2)container contains  left,center,right
(3)left contains  image,p
(4)right contains  image.p
(5)center contains image,p



(1)code for  index.html  file":

<html>
<head>
<link rel="stylesheet"   type="text/css"  href="css/style.css">
</head>
<body>
<div    class="main">
<div  class=header>
<div id=menu>
<img src="img/bootstrap.png "  id=logo>
</div>
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>contact us</li>
</ul>
</div>
<div   class=container>
<div  class=left>
<img src="img/bootstrap.png"  class=image>
<p class=p> A "Hello, world!" program has become.

</p>
</div>
<div  class=center>
<img src="img/bootstrap.png"  class=image>
<p  class=p>A "Hello, world!" program has become.

</p>
</div>

<div class=right>
<img src="img/bootstrap.png"  class=image >
<p  class=p>A "Hello, world!" program has become.

</p>
</div>

</div>
<div  class=footer>
</div>
</div>
</body>
</html>
(2)code for   "style.css"   file:
.main
{

margin:0 auto;
background-color:yellow;
width:800px;

}

#logo
{

float:left;
margin-top:20px;
height:60px;
width:200px;

}

.header
{
margin:0 auto;
height:100px;
width:700px;
background-color:pink;
}

ul
{
float:left;
margin-left:80px;
margin-top:60px;
list-style-type:none;


}


li
{

display:block;
float:left;
padding-left:10px;
margin-left:20px;
border-radius:20px;
background-color:red;


}

.container
{

margin:0 auto;
height:200px;
width:700px;
background-color:orange;
}

.left
{
margin-top:20px;
margin-left:20px;
float:left;
width:200px;
height:100px;
background-color:white;
}





.center
{
margin-top:20px;
margin-left:20px;
float:left;
width:200px;
height:100px;
background-color:white;
}
.right
{
margin-top:20px;
margin-left:20px;
float:left;
width:200px;
height:100px;
background-color:white;
}

.image
{
float:left;
height:60px;
width:60px;
}

.p
{
text-align:justify;
float:left;
width:100px;

}

.footer
{
margin:0 auto;
height:50px;
width:700px;
background-color:green;
}



Tuesday, 18 August 2015

FACEBOOK TYPE SEARCH BOX AUTOMATIC USING JQUERY & AJAX & PHP

PHP    CODE        FOR      SEARCHING        EXAMPLE      LIKE      FACEBOOK:

(1)CREATE TABLE    test_auto_complete :

Create table   test_auto_complete
(uid    int(10), 
Username  varchar(200), 
Email   varchar(200),
media   varchar(200),
country  varchar(200));

(2)write      code   for       “searchform.html”  :
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.8.0.min.js"></script>
<style type="text/css">
        body{
                font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;
        }
        .contentArea{
                width:600px;
                margin:0 auto;
        }
        #inputSearch
        {
                width:350px;
                border:solid 1px #000;
                padding:3px;
        }
        #divResult
        {
                position:absolute;
                width:350px;
                display:none;
                margin-top:-1px;
                border:solid 1px #dedede;
                border-top:0px;
                overflow:hidden;
                border-bottom-right-radius: 6px;
                border-bottom-left-radius: 6px;
                -moz-border-bottom-right-radius: 6px;
                -moz-border-bottom-left-radius: 6px;
                box-shadow: 0px 0px 5px #999;
                border-width: 3px 1px 1px;
                border-style: solid;
                border-color: #333 #DEDEDE #DEDEDE;
                background-color: white;
        }
        .display_box
        {
                padding:4px; border-top:solid 1px #dedede;
                font-size:12px; height:50px;
        }
        .display_box:hover
        {
                background:#3bb998;
                color:#FFFFFF;
                cursor:pointer;
        }
</style>

<script>

$(function(){
$(".search").keyup(function()
{
var inputSearch = $(this).val();
var dataString = 'searchword='+ inputSearch;
if(inputSearch!='')
{
      $.ajax({
      type: "POST",
      url: "search.php",
      data: dataString,
      cache: false,
      success: function(html)
      {
      $("#divResult").html(html).show();
      }
      });
}return false;   
});

jQuery("#divResult").live("click",function(e){
      var $clicked = $(e.target);
      var $name = $clicked.find('.name').html();
      var decoded = $("<div/>").html($name).text();
      $('#inputSearch').val(decoded);
});
jQuery(document).live("click", function(e) {
      var $clicked = $(e.target);
      if (! $clicked.hasClass("search")){
      jQuery("#divResult").fadeOut();
      }
});
$('#inputSearch').click(function(){
      jQuery("#divResult").fadeIn();
});
});


</script>



</head>




<body>



<div class="contentArea">
<input type="text" class="search" id="inputSearch" />Ex: om, arun, pranita<br />
<div id="divResult">
</div>
</div>


</body>
</html>

(2)write     code     for       “search.php”  file:

<?php
include('db.php');
if($_POST)
{
$q=$_POST['searchword'];
$sql_res=mysql_query("select uid,username,email,media,country from test_auto_complete where username like '%$q%' or email like '%$q%' order by uid LIMIT 5");
while($row=mysql_fetch_array($sql_res))
{
$username=$row['username'];
$email=$row['email'];
$media=$row['media'];
$country=$row['country'];
$b_username='<b>'.$q.'</b>';
$b_email='<b>'.$q.'</b>';
$final_username = str_ireplace($q, $b_username, $username);
$final_email = str_ireplace($q, $b_email, $email);
?>
<div class="display_box" align="left">
<img src="img/<?php echo $media; ?>" style="width:50px; height:50px; float:left; margin-right:6px;" /><span class="name"><?php echo $final_username; ?></span>&nbsp;<br/><?php echo $final_email; ?><br/>
<span style="font-size:9px; color:#999999"><?php echo $country; ?></span></div>
<?php
}
}
?>

note: img  is folder name where all images will be kept..



how to display all images from a folder using PHP SCRIPT

 see code in this  $folder is  holding  folder name "img"  & $filetype="type of image file"
<?php

$folder = 'img/';

$filetype = '*.*';

$files = glob($folder.$filetype);

$count = count($files);

echo '<table>';

for ($i = 0; $i < $count; $i++)
{
    echo '<tr><td>';
    echo '<a name="'.$i.'" href="#'.$i.'"><img src="'.$files[$i].'" /></a>';
    echo substr($files[$i],strlen($folder),strpos($files[$i], '.')-strlen($folder));
    echo '</td></tr>';
}

echo '</table>';

?>

Sunday, 16 August 2015

step by step guidance for library management project

Step 1:

Create table  book  & user given below:





Step 2: 
write code for  “addrecordform.php  file”:

<?php
session_start();
if(!isset($_SESSION['username']))
{
header('Location:error.php');
}

?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Theme Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="dist/css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="theme.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
<body role="document">
<form    action="addrecord.php"   method="post">
<table class="table">
<tr>
<td>Book Id</td><td><input type="text" name="bookid"></td>
</tr>
<tr>
<td>Book Name</td><td><input type="text" name="bookname"></td>
</tr>
<tr>
<td>Author Name</td><td><input type="text" name="authorname"></td>
</tr>
<tr>
<td>Publication Name</td><td><input type="text" name="publicationname"></td>
</tr>
<tr>
<td>Cost</td><td><input type="text" name="cost"></td>
</tr>
<tr>
<td>Edition</td><td><input type="text" name="edition"></td>
</tr>
<tr>
<td>Copies</td><td><input type="text" name="copies"></td>
</tr>
<tr>
<td>CD/DVD</td><td><input type="text" name="cddvd"></td>
</tr>
<tr>
<td>Book Heading</td><td><input type="text" name="bookheading"></td>
</tr>
<tr>
<td>Date</td><td><input type="text" name="date"></td>
</tr>
<tr>
<td>Location</td><td><input type="text" name="location"></td>
</tr>
<tr>
<td>Syllabus Reference</td><td><input type="text" name="syllabusreference"></td>
</tr>

<tr>

<td>
<input type="submit" value="submit" name="submit" class="btn btn-lg btn-primary btn-block">
</td><td></td>
</tr>
</table>
</form>
</body>
</html>

output:


(2)write     code     for     “addrecord.php”   file:
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("library",$con);
$bookid=$_POST["bookid"];
$bookname=$_POST["bookname"];
$authorname=$_POST["authorname"];
$publicationname=$_POST["publicationname"];
$cost=$_POST["cost"];
$edition=$_POST["edition"];
$copies=$_POST["copies"];
$cddvd=$_POST["cddvd"];
$bookheading=$_POST["bookheading"];
$date=$_POST["date"];
$location=$_POST["location"];
$syllabusreference=$_POST["syllabusreference"];
$sql="insert into book (bookid,bookname,authorname,publicationname,cost,edition,copies,cddvd,bookheading,date,location,syllabusreference)
values('$bookid','$bookname','$authorname','$publicationname','$cost','$edition','$copies','$cddvd','$bookheading','$date','$location','$syllabusreference')";
mysql_query($sql);
?>

(3)display  all record  from book  “display.php”   file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Theme Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="dist/css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="theme.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body role="document">
<?php
include("connect.php");
$sql="select * from book";
$result=mysql_query($sql);
echo'<table class="table">
<tr>
<td>BOOK ID</td>
<td>BOOK NAME</td>
<td>AUTHOR NAME</td>
<td>PUBLICATION NAME</td>
<td>COST</td>
<td>EDITION</td>
<td>COPIES</td>
<td>CD/DVD</td>
<td>BOOK HEADING</td>
<td>DATE</td>
<td>LOCATION</td>
<td>SYLLABUS REFERENCE</td>
<td></td>
<td></td>
</tr>';

while($row=mysql_fetch_array($result))
{
echo'<tr>';
echo'<td>';

echo $row["bookid"];
echo'</td>';
echo'<td>';

echo $row["bookname"];
echo'</td>';
echo'<td>';
echo $row["authorname"];
echo'</td>';
echo'<td>';
echo $row["publicationname"];
echo'</td>';
echo'<td>';
echo $row["cost"];
echo'</td>';
echo'<td>';
echo $row["edition"];
echo'</td>';
echo'<td>';
echo $row["copies"];
echo'</td>';
echo'<td>';
echo $row["cddvd"];
echo'</td>';
echo'<td>';
echo $row["bookheading"];
echo'</td>';
echo'<td>';
echo $row["date"];
echo'</td>';
echo'<td>';
echo $row["location"];
echo'</td>';
echo'<td>';
echo $row["syllabusreference"];
echo'</td>';
echo'<td>';
echo'<form action="update.php" method="post">
<input type="hidden" name="hidden"  value="'.$row['bookid'].'">
<input type="submit" name="update" value="update"></form>';
echo'</td>';

echo'<td>';
echo'<form action="delete.php" method="post">
<input type="hidden" name="hidden" value="'.$row['bookid'].'">
<input type="submit" name="delete" value="delete"></form>';
echo'</td>';
echo'</tr>';
}
echo'</table>';
?>
</body>
</html>

output:


(3)now code for  update.php   file :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Theme Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="dist/css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="theme.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body role="document">
<?php
$hidden=$_POST["hidden"];

include("connect.php");
$sql="select * from book where bookid='$hidden'";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{

echo'<form action="updatenext.php" method="post">';
echo'<table class="table table-bordered">';
echo'<tr>';
echo'<td>BOOK ID</td><td><input type="text" name="bookid" value="'.$row['bookid'].'"></td></tr>';
echo'<tr><td>BOOK NAME</td><td><input type="text" name="bookname" value="'.$row['bookname'].'"></td></tr>';
echo'<tr><td>AUTHOR NAME</td><td><input type="text" name="authorname" value="'.$row['authorname'].'"></td></tr>';
echo'<tr><td>PUBLICATION NAME</td><td><input type="text" name="publicationname" value="'.$row['publicationname'].'"></td></tr>';
echo'<tr><td>COST</td><td><input type="text" name="cost" value="'.$row['cost'].'"></td></tr>';
echo'<tr><td>EDITION</td><td><input type="text" name="edition" value="'.$row['edition'].'"></td></tr>';
echo'<tr><td>COPIES</td><td><input type="text" name="copies" value="'.$row['copies'].'"></td></tr>';
echo'<tr><td>CD/DVD</td><td><input type="text" name="cddvd" value="'.$row['cddvd'].'"></td></tr>';
echo'<tr><td>BOOK HEADING</td><td><input type="text" name="bookheading" value="'.$row['bookheading'].'"></td></tr>';
echo'<tr><td>DATE</td><td><input type="text" name="date" value="'.$row['date'].'"></td></tr>';
echo'<tr><td>LOCATION</td><td><input type="text" name="location" value="'.$row['location'].'"></td></tr>';
echo'<tr><td>SYLLABUS REFERENCE</td><td><input type="text" name="syllabusreference" value="'.$row['syllabusreference'].'"></td></tr>';
echo'<tr><td></td><td><input type="hidden" name="hidden" value="'.$row['bookid'].'">';
echo'<input type="submit" name="update" value="update"></td></tr></tr>';
echo'</form>';
}

?>
</body>
</html>

output:


(4)now   code for    updatenext.php   file:
<?php
include("connect.php");
$hidden=$_POST["hidden"];

$bookid=$_POST["bookid"];
$bookname=$_POST["bookname"];
$authorname=$_POST["authorname"];
$publicationname=$_POST["publicationname"];
$cost=$_POST["cost"];
$edition=$_POST["edition"];
$copies=$_POST["copies"];
$cddvd=$_POST["cddvd"];
$bookheading=$_POST["bookheading"];
$date=$_POST["date"];
$location=$_POST["location"];
$syllabusreference=$_POST["syllabusreference"];
$sql="update book set bookid='$bookid',bookname='$bookname',authorname='$authorname',publicationname='$publicationname',cost='$cost',edition='$edition',
copies='$copies',cddvd='$cddvd',bookheading='$bookheading',date='$date',location='$location',syllabusreference='$syllabusreference' where bookid='$hidden'";
mysql_query($sql);
echo “record updated successfully”;
?>
(5) code for  delete.php    file :

<?php
include("connect.php");
$hidden=$_POST["hidden"];
$sql="delete from book where bookid='$hidden'";
mysql_query($sql);
?>

(6)Now     code   for   searching     “searchform.html” :

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Theme Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="dist/css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="theme.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
                <script>
function ajax_post(){
    // Create our XMLHttpRequest object
    var hr = new XMLHttpRequest();
    // Create some variables we need to send to our PHP file
               
    var url = "search.php";
               
    var fn = document.getElementById("bookid").value;
               
               
  
                var vars = "bookid="+fn;
               
    hr.open("POST", url, true);
    // Set content type header information for sending url encoded variables in the request
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    // Access the onreadystatechange event for the XMLHttpRequest object
    hr.onreadystatechange = function() {
                    if(hr.readyState == 4 && hr.status == 200) {
                                    var return_data = hr.responseText;
                                                document.getElementById("status").innerHTML = return_data;
                    }
    }
    // Send the data to PHP now... and wait for response to update the status div
    hr.send(vars); // Actually execute the request
    document.getElementById("status").innerHTML = "processing...";
}
</script>
  </head>
  <body role="document">

<input type="text" name="bookid"  id="bookid">
<input type="submit" name="search" value="search"   onclick="ajax_post();">

<div id="status">

</div>
</body>
</html>



(7)code     for    “ search.php”       file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Theme Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="dist/css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="theme.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body role="document">
<?php
include("connect.php");
$bookid=$_POST["bookid"];

$sql="select * from book  where bookid='$bookid'";
$result=mysql_query($sql);
echo'<table class="table">';
echo'<thead>';
echo'<tr><th>BOOK ID</th><th>BOOK NAME</th><th>AUTHOR NAME</th><th>PUBLICATION NAME</th><th>COST</th><th>EDITION</th>
<th>COPIES</th><th>CD/DVD</th><th>BOOK HEADING</th><th>DATE</th><th>LOCATION</th><th>SYLLABUS REFERENCE</th><th></th><th></th></tr>';
echo'</thead>';
while($row=mysql_fetch_array($result))
{
echo'<tr>';
echo'<td>';

echo $row["bookid"];
echo'</td>';
echo'<td>';
echo $row["bookname"];
echo'</td>';
echo'<td>';
echo $row["authorname"];
echo'</td>';
echo'<td>';
echo $row["publicationname"];
echo'</td>';
echo'<td>';
echo $row["cost"];
echo'</td>';
echo'<td>';
echo $row["edition"];
echo'</td>';
echo'<td>';
echo $row["copies"];
echo'</td>';
echo'<td>';
echo $row["cddvd"];
echo'</td>';
echo'<td>';
echo $row["bookheading"];
echo'</td>';
echo'<td>';
echo $row["date"];
echo'</td>';
echo'<td>';
echo $row["location"];
echo'</td>';
echo'<td>';
echo $row["syllabusreference"];
echo'</td>';
echo'<td>';
echo'<form action="update.php" method="post">
<input type="hidden" name="hidden"  value="'.$row['bookid'].'">
<input type="submit" name="update" value="update"></form>';
echo'</td>';

echo'<td>';
echo'<form action="delete.php" method="post">
<input type="hidden" name="hidden" value="'.$row['bookid'].'">
<input type="submit" name="delete" value="delete"></form>';
echo'</td>';
echo'</tr>';
}
echo'</table>';
?>
</body>
</html>

output:










Browsers

Powered by Blogger.

Feature Post

About Me

My photo
B.E.(COMPUTER ENGINEER) PHP Web developer & Provide Training for Web Development , Digital Marketing ,Android Mobile Apps Development

Post Slider (Homepage)

Blog Archive

Malwares

Transfer Files

Media Players

Download Manager

Window

Torrents Soft

Developer Tools

Botton Ad

Ads

Newsletter

 

© 2013 PHP TRAINING IN MUMBAI BY OM SIR . All rights resevered. Designed by OM SIR

Back To Top