-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp_update_data_from_mysql_database_table.php
69 lines (41 loc) · 1.27 KB
/
php_update_data_from_mysql_database_table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// php code to Update data from mysql database Table
if(isset($_POST['update']))
{
$hostname = "localhost";
$username = "root";
$password = "";
$databaseName = "ciit_db";
$connect = mysqli_connect($hostname, $username, $password, $databaseName);
// get values form input text and number
$id = $_POST['id'];
$fname = $_POST['fname'];
echo $id;
echo $fname;
// mysql query to Update data
$query = "UPDATE `ciit_login` SET u_name ="."'$fname'"."'WHERE u_pass="."'$id'";
$result = mysqli_query($connect, $query);
if($result)
{
echo 'Data Updated';
}else{
echo 'Data Not Updated';
}
mysqli_close($connect);
}
?>
<!DOCTYPE html>
<html>
<head>
<title> PHP UPDATE DATA </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="php_update_data_from_mysql_database_table.php" method="post">
ID To Update: <input type="text" name="id" required><br><br>
New First Name:<input type="text" name="fname" required><br><br>
<input type="submit" name="update" value="Update Data">
</form>
</body>
</html>