Skip to main content

Posts

How to pass data from html form to php file on server using jquery $.ajax :-

Pass  data from  html form to php file on server using jquery $.ajax :- Step 1:- Write code for  form.html file:- <!doctype html> <html lang="en"> <head> <title>passing form input value to php - BY OM SIR</title>   <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript"> $(document).ready(function (event) { // triggered when the form submitted $("#myform").submit(function(event) { event.preventDefault(); $("#response").empty(); $.ajax({ // URL to move the uploaded image file to server url: "pass.php", // Request type type: "POST", // To send the full form data data: new FormData(this), contentType: false,  processData:false,  // UI response after the file upload success: function(data) { $("#response").html(data); } }); }); // Triggered when the imag
Recent posts

Jquery Pop Up example for login and Registration form

<!DOCTYPE html> <html lang="en"> <head>   <title>Bootstrap Example</title>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>     <style> #login{ display:none; } #register{ display:none; } </style> <script> $(document).ready(function(){     $("#click1").click(function(){         $("#login").show();   $("#register").hide();     }); }); $(document).ready(function(){     $("#click2").click(function(){         $("#registe

how to parse php array to json

PHP JSON Parsing What is JSON JSON stands for  J ava S cript  O bject  N otation. JSON is a standard lightweight data-interchange format which is quick and easy to parse and generate. JSON, like XML, is a text-based format that's easy to write and easy to understand for both humans and computers, but unlike XML, JSON data structures occupy less bandwidth than their XML versions. JSON is based on two basic structures: ·          Object:  This is defined as a collection of key/value pairs (i.e.  key:value ). Each object begins with a left curly bracket  {  and ends with a right curly bracket  } . Multiple key/value pairs are separated by a comma  , . ·          Array:  This is defined as an ordered list of values. An array begins with a left bracket  [  and ends with a right bracket  ] . Values are separated by a comma  , . In JSON, keys are always strings, while the value can be a  string ,  number ,  true  or  false ,  null  or even an  object  or an  array . Strings

insert multiple fields using foreach loop

create  a  table     students: SQL>      create table  students  (id   int primary key auto_increment,    name    varchar(200),   age  varchar(200) ); <?php if (isset($_POST['submit'])) { $i = 0;     foreach ($_POST as $val) {          $name = $_POST['name'][$i];     $age = $_POST['age'][$i]; $con=mysqli_connect("localhost","root","","abhi"); $sql="INSERT INTO students (name,age) VALUES ('$name','$age')";         $result=mysqli_query($con,$sql); $i++; if($result) { echo "record inserted"; }     } } ?> <h1>Add user</h1>  <form method="post" action="test.php">  <table>     <thead>         <th>Name</th>         <th>Age</th>     </thead>     <tr>         <td><input name="name[]" type="text" />

php pagination script with mysqli

<?php     $con=mysqli_connect("localhost","root","","payroll");       $per_page = 2; //per page record   $pages_query = mysqli_query($con, 'SELECT COUNT(id) FROM employee'); $row = mysqli_fetch_array($pages_query); $pages = ceil($row[0] / $per_page);   //echo $pages;       $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; //page number throung url     $start = ($page - 1) * $per_page;   $sql="SELECT *  FROM employee LIMIT $start, $per_page";     $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)) { echo "id is" .$row['id']; echo $row['name']; echo $row['phone']; echo $row['salary']; echo '<br>'; } $prev = $page - 1;     $next = $page + 1;       if(!($page<=1)) {         echo "<a href='pag.php?page=$prev'>Prev</a> ";     }

how to display multiple checkbox value from database in php

Step 1:   SQL> create table  userrecord ( id int primary key , name   varchar(200) ); Step 2: write code for checkbox.php file: <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "ankit"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) {     die("Connection failed: " . mysqli_connect_error()); } $sql="select * from userrecord"; $result=mysqli_query($conn,$sql); while ($row=mysqli_fetch_array($result)) { echo '<form action="select.php" method="post"> <input type="checkbox" name="check_list[]" value="'.$row['id'].'"><label> "'.$row['name'].'"</label><br/>'; } echo '<input type="submit" name="submit" value="Submit"/&

PHP interview Questions

1.   What is PHP? PHP is a  server  side  scripting language  commonly used for web applications. PHP has many frameworks and cms for creating websites.Even a non technical person can cretae sites using its CMS.WordPress,osCommerce are the famus CMS of php.It is also an object oriented programming language like java,C-sharp etc.It is very eazy for learning 2.   What is the use of "echo" in php? It is used to print a data in the webpage, Example: <?php echo 'Car insurance'; ?> , The following code print the text in the webpage 3.   How to include a file to a php page? We can include a file using "include() " or "require()" function with  file path  as its  parameter . 4.   What's the difference between include and require? If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue. 5.

Popular posts from this blog

how to display multiple checkbox value from database in php

Step 1:   SQL> create table  userrecord ( id int primary key , name   varchar(200) ); Step 2: write code for checkbox.php file: <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "ankit"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) {     die("Connection failed: " . mysqli_connect_error()); } $sql="select * from userrecord"; $result=mysqli_query($conn,$sql); while ($row=mysqli_fetch_array($result)) { echo '<form action="select.php" method="post"> <input type="checkbox" name="check_list[]" value="'.$row['id'].'"><label> "'.$row['name'].'"</label><br/>'; } echo '<input type="submit" name="submit" value="Submit"/&

PHP interview Questions

1.   What is PHP? PHP is a  server  side  scripting language  commonly used for web applications. PHP has many frameworks and cms for creating websites.Even a non technical person can cretae sites using its CMS.WordPress,osCommerce are the famus CMS of php.It is also an object oriented programming language like java,C-sharp etc.It is very eazy for learning 2.   What is the use of "echo" in php? It is used to print a data in the webpage, Example: <?php echo 'Car insurance'; ?> , The following code print the text in the webpage 3.   How to include a file to a php page? We can include a file using "include() " or "require()" function with  file path  as its  parameter . 4.   What's the difference between include and require? If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue. 5.

JQUERY CODE FOR PREVIEW AND UPLOADING IMAGE