Thursday, 13 June 2019

Update data in mysql using php form

page name updatedata.php and Column in table : id , uid , upass , email.

 <!DOCTYPE html>
<link href="style.css" rel="stylesheet" type="text/css">
<div class="maindiv">
<div class="divA">
<div class="title">
<h2>Update Data </h2>
<div class="divB">
<div class="divD">
<p>Click On Menu</p>
$connection = mysql_connect("localhost", "root", "root password");
$db = mysql_select_db("db name", $connection);
if (isset($_GET['submit'])) {
$id = $_GET['did'];
$name = $_GET['dname'];
$email = $_GET['demail'];
$mobile = $_GET['dmobile'];

$query = mysql_query("update admin_log set
id='$id',uid='$name', email='$email', upass='$mobile' where id='$id'", $connection);
$query = mysql_query("select * from admin_log", $connection);
while ($row = mysql_fetch_array($query)) {
echo "<b><a href='updatedata.php?update={$row['id']}'>{$row['upass']}</a></b>";
echo "<br />";
if (isset($_GET['update'])) {
$update = $_GET['update'];
$query1 = mysql_query("select * from admin_log where id=$update", $connection);
while ($row1 = mysql_fetch_array($query1)) {
echo "<form class='form' method='get'>";
echo "<h2>Update Form</h2>";
echo "<hr/>";
echo"<input class='input' type='hidden' name='did' value='{$row1['id']}' />";
echo "<br />";
echo "<label>" . "Name:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='dname' value='{$row1['uid']}' />";
echo "<br />";
echo "<label>" . "Email:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='demail' value='{$row1['email']}' />";
echo "<br />";
echo "<label>" . "Password:" . "</label>" . "<br />";
echo"<input class='input' type='text' name='dmobile' value='{$row1['upass']}' />";

echo "</textarea>";
echo "<br />";
echo "<input class='submit' type='submit' name='submit' value='update' />";
echo "</form>";
if (isset($_GET['submit'])) {
echo '<div class="form" id="form3"><br><br><br><br><br><br>
<Span>Data Updated Successfuly......!!<br><br></span></div>';
<div class="clear"></div>
<div class="clear"></div>

1 comment:

  1. Your share in this article is very helpful to me, I have often read your article. Thank you.
    Chung tôi cung cấp tới quý khách hàng những dịch vụ tốt nhất hiện nay như: dịch vụ vận tải, dịch vụ chuyển phát nhanh, cho thuê xe tải, ship cod toàn quốc,... Chúng tôi tự tin đảm bảo chất lượng dịch vụ tốt nhất, uy tín và giá cả phù hợp nhất.