-
Notifications
You must be signed in to change notification settings - Fork 3
/
update.php
54 lines (54 loc) · 1.67 KB
/
update.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
<?php
require('session.php');
?>
<?php
//PROGRAM : PHP program to UPDATE a Record in MySQL database for the CRUD App
//CODED BY : SUMAN GANGOPADHYAY
//DATABASE NAME : php_mysqli
//Table Name : userinfo
//DATE : 20-July-2014
$id = $_GET['id'];
$user = 'root';
$password = 'suman';
$ip = 'localhost';
$dbname = 'php_mysqli';
$connection_update = mysqli_connect($ip, $user, $password, $dbname);
$id = $_GET['id'];
if (!mysqli_connect_errno()){
$query = "SELECT `name`,`user`,`password` FROM login_system WHERE `id`='{$id}'";
$result = mysqli_query($connection_update,$query);
if ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$name=$row['name'];
$login_id=$row['user'];
$user_password=$row['password'];
}
}else{
echo "ERROR : Database connection failed !"."<br>";
}
mysqli_close($connection_update);
require('update.html');
//Update the data and Save it into the MySQL database;
if (isset($_POST['submit'])) {
$user = 'root';
$password = 'suman';
$ip = 'localhost';
$dbname = 'php_mysqli';
$fname = $_POST['username'];
$login = $_POST['login'];
$psw = $_POST['psw'];
$connection_write = mysqli_connect($ip, $user, $password, $dbname);
if (!mysqli_connect_errno()) {
$visibility = 1;
$query = "UPDATE login_system SET `name`='{$fname}',`user`='{$login}',
`password`='{$psw}' WHERE `id`='{$id}' ";
if(mysqli_query($connection_write, $query)){
header("location:conf.php");
}else{
echo "<script>alert('ERROR : Database Insert Failed because login name exists');</script>";
}
}else{
die("ERROR : ".mysqli_connect_error());
}
mysqli_close($connection_write);
}
?>