HIDDEN CONCEPT
UPDATE & DELETE USING HIDDEN CONCEPT USING MYSQL :
(1)FIRST CREATE TABLE:
Create table record
(id int,
name varchar(20),
email varchar(20),
password varchar(20)
);
(2)
(2)Insert record into table for example :
insert record into (id,name,email,password)values(‘1’,’om’,’om@gmail.com’,’@1234’);
(3)write code for display.php:
<?php
$con =mysql_connect("localhost","root","");
mysql_select_db("bibhu",$con);
$sql = "select * from record";
$result = mysql_query($sql);
echo '<table border=1>
<tr> <td>id</td><td>name</td><td>email</td><td>password</td><td> </td><td> </td></tr>';
while($row=mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>';
echo $row['id'];
echo '</td>';
echo '<td>';
echo $row['name'];
echo '</td>';
echo '<td>';
echo $row["email"];
echo '</td>';
echo '<td>';
echo $row["password"];
echo '</td>';
echo '<td> <form action="update.php" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"name="button" value="update">
</form></td>';
echo '<td> <form action="delete.php"method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"name="button"value="delete">
</form></td>';
echo'</tr>';
}
echo'</table>';
?>
(4)write code for “update.php” file:
<?php
$hidden=$_POST["hidden"];
$con =mysql_connect("localhost","root","");
mysql_select_db("bibhu",$con);
$sql = "select * from record where id='$hidden'";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo '<form action="finalupdate.php" method="post">
id <input type="text" name="id" value="'.$row['id'].'">
Name <input type="text" name="name" value="'.$row['name'].'">
email <input type="text" name="email" value="'.$row['email'].'">
password<input type="text" name="password" value="'.$row['password'].'">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"value="update"name="update">
</form>';
}
?>
ouput:
(5)write code for “finalupdate.php “:
<?php
$hidden=$_POST["hidden"];
$name=$_POST["name"];
$email=$_POST["email"];
$password=$_POST["password"];
$con=mysql_connect("localhost","root","");
mysql_select_db("bibhu",$con);
$sql="update record set name='$name', email='$email',password='$password' where id='$hidden'";
mysql_query($sql);
echo"record updated successfully";
?>
(6)Now for delete write code for “delete .php “ file:
<?php
$hidden=$_POST["hidden"];
$con=mysql_connect("localhost","root","");
mysql_select_db("bibhu",$con);
$sql="delete from record where id='$hidden'";
mysql_query($sql);
echo"record deleted successfully";
?>
=======================================================================
HIDDEN CONCEPT USING JAVASCRIPT:
======================================================================
First of all create table user & insert 10 values :
SQL>
create table users
(user_id int,
first_name varchar(200),
last_name varchar(200),
user_city varchar(200)
);
(1)WRITE CODE FOR display.php file:
<html>
<head>
<script type="text/javascript">
function update_id(id)
{
if(confirm('do you want to update'))
{
window.location.href='update.php?update_id='+id;
}
}
</script>
<script type="text/javascript">
function delete_id(id)
{
if(confirm('Sure To Remove This Record ?'))
{
window.location.href='delete.php?delete_id='+id;
}
}
</script>
</head>
<body>
<?php
mysql_connect("localhost","root","");
mysql_select_db("ajax");
$sql_query="SELECT * FROM users";
$result_set=mysql_query($sql_query);
?>
<table align="center" >
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>City</th>
<th>Delete</th>
</tr>
<?php
if(mysql_num_rows($result_set)>0)
{
while($row=mysql_fetch_array($result_set))
{
?>
<tr>
<td><?php echo $row['user_id']; ?></td>
<td><?php echo $row['first_name']; ?></td>
<td><?php echo $row['last_name']; ?></td>
<td align="center"><a href="javascript:update_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="UPDATE" /></a></td>
<td align="center"><a href="javascript:delete_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="Delete" /></a></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<th colspan="4">There's No data found !!!</th>
</tr>
<?php
}
?>
</table>
</body>
</html>
(2)write code for update.php file:
<html>
<head>
<script type="text/javascript">
function finalupdate_id(id)
{
if(confirm('do you want to update'))
{
window.location.href='finalupdate.php?finalupdate_id='+id;
}
}
</script>
</head>
<body>
<?php
if(isset($_GET['update_id']))
{
$hidden=$_GET['update_id'];
$con =mysql_connect("localhost","root","");
mysql_select_db("ajax",$con);
$sql = "select * from users where user_id='$hidden'";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo '<form action="finalupdate.php" method="post">
id <input type="text" name="id" value="'.$row['user_id'].'">
Name <input type="text" name="name" value="'.$row['first_name'].'">
email <input type="text" name="email" value="'.$row['last_name'].'">
password<input type="text" name="password" value="'.$row['user_city'].'">';
?>
<a href="javascript:finalupdate_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="finalUPDATE" /></a>
<?php
echo '</form>';
}
}
?>
</body>
</html>
(4)write code for delete.php file:
<?php
if(isset($_GET['delete_id']))
{
echo $_GET['delete_id'];
}
?>
HIDDEN CONCEPT USING MYSQLI :
first of write code for database connectivity file name connect.php:
<?php
$con =mysqli_connect("localhost","root","","prakash");
if($con)
{
echo "connected";
}
else
{
echo "not connected";
}
?>
(1)write code for display.php file:
<?php
$con =mysqli_connect("localhost","root","","prakash"); //database connectivity
$sql = "select * from hidden"; //select all record from table hideen
$result = mysqli_query($con,$sql); //exceute sql
echo '<table class="prakash">
<tr> <th>id</th><th>name</th><th>email</th><th>password</th><th> </th><th> </th></tr>';
while($row=mysqli_fetch_array($result)) //reading table record using mysqli_fetch_array()
{
echo '<tr>';
echo '<td>';
echo $row['id']; //display id value from column id
echo '</td>';
echo '<td>';
echo $row['name']; //display name value from column name
echo '</td>';
echo '<td>';
echo $row["email"]; //display email value from column email
echo '</td>';
echo '<td>';
echo $row["password"]; //display password value from column password
echo '</td>';
echo '<td> <form action="update.php" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"name="button" value="update">
</form></td>';
echo '<td> <form action="delete.php"method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"name="button"value="delete">
</form></td>';
echo'</tr>';
}
echo'</table>';
?>
(2)wrie code for update.php file :
<?php
$hiddenid=$_POST["hidden"]; //getting id from hidden element from display.php
include('connect.php');
$sql = "select * from hidden where id='$hiddenid'";
$result = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
{
echo '<form action="finalupdate.php" method="post">
id <input type="text" name="id" value="'.$row['id'].'">
Name <input type="text" name="name" value="'.$row['name'].'">
email <input type="text" name="email" value="'.$row['email'].'">
password<input type="text" name="password" value="'.$row['password'].'">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"value="update"name="update">
</form>';
}
?>
(3)write code for finalupdate.php file :
<?php
$hiddenid=$_POST["hidden"];
$name=$_POST["name"];
$email=$_POST["email"];
$password=$_POST["password"];
include('connect.php');
$sql="update hidden set name='$name', email='$email',password='$password' where id='$hiddenid'";
$res=mysqli_query($con,$sql);
if($res)
{
echo"record updated successfully";
}
else
{
echo "record not updated";
}
?>
(4)write code for delete.php file:
<?php
include('connect.php'); //it ll include all code of connect.php
$hiddenid=$_POST['hidden']; // value from display.php
$sql="delete from hidden where id='$hiddenid'";
$res=mysqli_query($con,$sql); //go and exceute delete sql command
if ($res)
{
echo "deleted";
}
else
{
echo "not deleted";
}
?>
========================================================================
HIDDEN CONCEPT USING AJAX & JQUERY:
========================================================================
=======================================================================
HIDDEN CONCEPT USING JAVASCRIPT:
======================================================================
First of all create table user & insert 10 values :
SQL>
create table users
(user_id int,
first_name varchar(200),
last_name varchar(200),
user_city varchar(200)
);
(1)WRITE CODE FOR display.php file:
<html>
<head>
<script type="text/javascript">
function update_id(id)
{
if(confirm('do you want to update'))
{
window.location.href='update.php?update_id='+id;
}
}
</script>
<script type="text/javascript">
function delete_id(id)
{
if(confirm('Sure To Remove This Record ?'))
{
window.location.href='delete.php?delete_id='+id;
}
}
</script>
</head>
<body>
<?php
mysql_connect("localhost","root","");
mysql_select_db("ajax");
$sql_query="SELECT * FROM users";
$result_set=mysql_query($sql_query);
?>
<table align="center" >
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>City</th>
<th>Delete</th>
</tr>
<?php
if(mysql_num_rows($result_set)>0)
{
while($row=mysql_fetch_array($result_set))
{
?>
<tr>
<td><?php echo $row['user_id']; ?></td>
<td><?php echo $row['first_name']; ?></td>
<td><?php echo $row['last_name']; ?></td>
<td align="center"><a href="javascript:update_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="UPDATE" /></a></td>
<td align="center"><a href="javascript:delete_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="Delete" /></a></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<th colspan="4">There's No data found !!!</th>
</tr>
<?php
}
?>
</table>
</body>
</html>
(2)write code for update.php file:
<html>
<head>
<script type="text/javascript">
function finalupdate_id(id)
{
if(confirm('do you want to update'))
{
window.location.href='finalupdate.php?finalupdate_id='+id;
}
}
</script>
</head>
<body>
<?php
if(isset($_GET['update_id']))
{
$hidden=$_GET['update_id'];
$con =mysql_connect("localhost","root","");
mysql_select_db("ajax",$con);
$sql = "select * from users where user_id='$hidden'";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo '<form action="finalupdate.php" method="post">
id <input type="text" name="id" value="'.$row['user_id'].'">
Name <input type="text" name="name" value="'.$row['first_name'].'">
email <input type="text" name="email" value="'.$row['last_name'].'">
password<input type="text" name="password" value="'.$row['user_city'].'">';
?>
<a href="javascript:finalupdate_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="finalUPDATE" /></a>
<?php
echo '</form>';
}
}
?>
</body>
</html>
(3)write code for finalupdate.php file:
<?php
if(isset($_GET['finalupdate_id']))
{
echo $_GET['finalupdate_id'];
}
?>
(4)write code for delete.php file:
<?php
if(isset($_GET['delete_id']))
{
echo $_GET['delete_id'];
}
?>
HIDDEN CONCEPT USING MYSQLI :
(1)FIRST CREATE TABLE:
Create table record
(id int,
name varchar(20),
email varchar(20),
password varchar(20)
);
(2)Insert record into table for example :
insert record into (id,name,email,password)values(‘1’,’om’,’om@gmail.com’,’@1234’);
first of write code for database connectivity file name connect.php:
<?php
$con =mysqli_connect("localhost","root","","prakash");
if($con)
{
echo "connected";
}
else
{
echo "not connected";
}
?>
(1)write code for display.php file:
<?php
$con =mysqli_connect("localhost","root","","prakash"); //database connectivity
$sql = "select * from hidden"; //select all record from table hideen
$result = mysqli_query($con,$sql); //exceute sql
echo '<table class="prakash">
<tr> <th>id</th><th>name</th><th>email</th><th>password</th><th> </th><th> </th></tr>';
while($row=mysqli_fetch_array($result)) //reading table record using mysqli_fetch_array()
{
echo '<tr>';
echo '<td>';
echo $row['id']; //display id value from column id
echo '</td>';
echo '<td>';
echo $row['name']; //display name value from column name
echo '</td>';
echo '<td>';
echo $row["email"]; //display email value from column email
echo '</td>';
echo '<td>';
echo $row["password"]; //display password value from column password
echo '</td>';
echo '<td> <form action="update.php" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"name="button" value="update">
</form></td>';
echo '<td> <form action="delete.php"method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"name="button"value="delete">
</form></td>';
echo'</tr>';
}
echo'</table>';
?>
(2)wrie code for update.php file :
<?php
$hiddenid=$_POST["hidden"]; //getting id from hidden element from display.php
include('connect.php');
$sql = "select * from hidden where id='$hiddenid'";
$result = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
{
echo '<form action="finalupdate.php" method="post">
id <input type="text" name="id" value="'.$row['id'].'">
Name <input type="text" name="name" value="'.$row['name'].'">
email <input type="text" name="email" value="'.$row['email'].'">
password<input type="text" name="password" value="'.$row['password'].'">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit"value="update"name="update">
</form>';
}
?>
(3)write code for finalupdate.php file :
<?php
$hiddenid=$_POST["hidden"];
$name=$_POST["name"];
$email=$_POST["email"];
$password=$_POST["password"];
include('connect.php');
$sql="update hidden set name='$name', email='$email',password='$password' where id='$hiddenid'";
$res=mysqli_query($con,$sql);
if($res)
{
echo"record updated successfully";
}
else
{
echo "record not updated";
}
?>
(4)write code for delete.php file:
<?php
include('connect.php'); //it ll include all code of connect.php
$hiddenid=$_POST['hidden']; // value from display.php
$sql="delete from hidden where id='$hiddenid'";
$res=mysqli_query($con,$sql); //go and exceute delete sql command
if ($res)
{
echo "deleted";
}
else
{
echo "not deleted";
}
?>
========================================================================
HIDDEN CONCEPT USING AJAX & JQUERY:
========================================================================
First create table :
Create table abc
(id int primary key auto_increment ,
fullname varchar(200),
email varchar(200),
password varchar(200)
);
Then insert at least 5 records in your table.
(1)write code for display.php file:
<html>
<head>
<!—download--- jquery.min.js --- file –from-- jquery.com----->
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="update.js"> </script>
<script type="text/javascript" src="delete.js"> </script>
</head>
<?php
$con=mysqli_connect("localhost","root","","databasename");
$sql="select * from abc";
$result=mysqli_query($con,$sql);
echo '<table border=1>
<tr><td>id</td>
<td>fullname</td>
<td>email</td>
<td>password</td>
<td> </td><td> </td></td></tr>';
while($row=mysqli_fetch_array($result))
{
echo '<tr>';
echo '<td>';
echo $row['id'];
echo '</td>';
echo '<td>';
echo $row['fullname'];
echo '</td>';
echo '<td>';
echo $row['email'];
echo '</td>';
echo '<td>';
echo $row["password"];
echo '</td>';
echo '<td>
<form id="update" action="" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit" name="submit" value="update"> <br></br>
</form>
</td>';
echo '<td>
<form id="delete" action="" method="post">
<input type="hidden" name="hidden" value="'.$row['id'].'">
<input type="submit" name="submit" value="delete"> <br></br>
</form>
</td>';
echo '</tr>';
}
echo'</table>';
?>
<div id=update_status> </div>
<div id=delete_status> </div>
<div id=final-update_status> </div>
(2)write code for update.js file:
$(document).ready(function (event) {
// triggered when the form submitted
$("#update").on('submit',(function(event) {
event.preventDefault();
$("#update_status").empty();
$.ajax({
// URL to move the uploaded image file to server
url: "update.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)
{
$("#update_status").html(data);
}
});
}));
// Triggered when the image changed (browse)
// Function to show the image as a preview
});
(3)write code for update.php file:
<html>
<head>
<script type="text/javascript" src="final-update.js"></script>
</head>
<?php
$hidden=$_POST["hidden"];
$con=mysqli_connect("localhost","root","","zaid");
$sql="select * from abc where id='$hidden'";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
{
echo '<form id="final-update" action="" method="post">';
echo 'fullname<input type="text" name="fullname" value="'.$row['fullname'].'">';
echo '
email<input type="text" name="email" value="'.$row['email'].'">';
echo '
password<input type="text" name="password" value="'.$row['password'].'"> ';
echo '
<input type="hidden" name="hidden" value="'.$row['id'].'">';
echo '
<input type="submit" value="update" name="update">';
echo '</form>';
}
?>
(4)write code for final-update.js:
$(document).ready(function (event) {
// triggered when the form submitted
$("#final-update").on('submit',(function(event) {
event.preventDefault();
$("#final-update_status").empty();
$.ajax({
// URL to move the uploaded image file to server
url: "final-update.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)
{
$("#final-update_status").html(data);
}
});
}));
// Triggered when the image changed (browse)
// Function to show the image as a preview
});
(6)write code for final-update.php file:
<?php
$con=mysqli_connect("localhost","root","","zaid");
$hidden=$_POST['hidden'];
$fullname=$_POST['fullname'];
$email=$_POST['email'];
$password=$_POST['password'];
$sql="update abc set fullname='$fullname', email='$email',password='$password' where id='$hidden'";
$result=mysqli_query($con,$sql);
if($result)
{
echo "data update successfully";
}
else
{
echo "data not update";
}
?>
(6)write code for delete.js file:
$(document).ready(function (event) {
// triggered when the form submitted
$("#delete").on('submit',(function(event) {
event.preventDefault();
$("#delete_status").empty();
$.ajax({
// URL to move the uploaded image file to server
url: "delete.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)
{
$("#delete_status").html(data);
}
});
}));
// Triggered when the image changed (browse)
// Function to show the image as a preview
});
(7)write code for delete.php file:
<?php
$hidden=$_POST["hidden"];
$con=mysqli_connect("localhost","root","","zaid");
$sql="delete from abc where id='$hidden'";
$result=mysqli_query($con,$sql);
if($result)
{
echo "record deleted successfully";
}
else
{
echo "record not delete";
}
?>


Comments
Post a Comment