-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact_update.php
90 lines (85 loc) · 3.48 KB
/
contact_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
session_start();
if(!isset($_SESSION['FullName'])){
header('location:login_admin.php');
}
include 'connect.php';
$icon = "";
$selectquery = "SELECT * FROM `navbar4`";
$query = mysqli_query($con, $selectquery);
if($query){
$fav_icon = mysqli_fetch_assoc($query);
$icon = $fav_icon['Image'];
}
if(isset($_POST['submit'])){
$id = $_POST['Sr_No'];
$fname = $_POST['fname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$addr = $_POST['address'];
$msg = $_POST['message'];
$updatequery = "UPDATE `contact363` SET `FullName`='$fname', `Phone_No`='$phone', `Email`='$email', `Address`='$addr', `Message`='$msg', `Time`=current_timestamp() WHERE `Sr_No`=$id";
$query = mysqli_query($con, $updatequery);
if($query){ ?>
<script>
alert("Message changed successfully...");
location.replace('contact_details.php');
</script>
<?php }
else{ ?>
<script>
alert("Something went wrong...");
</script>
<?php }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Message</title>
<link rel="icon" type="image/png" href="images/<?php echo $icon; ?>" />
<link rel="stylesheet" href="footer_menu_add.css">
</head>
<body>
<?php
$id = $_GET['update'];
$selectquery = "SELECT * FROM `contact363` WHERE `Sr_No`='$id'";
$query = mysqli_query($con, $selectquery);
$row = mysqli_fetch_assoc($query);
?>
<section id="container">
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
<h2>Add Message</h2>
<div class="input">
<label for="fname">Full Name</label>
<input type="text" id="fname" name="fname" value="<?php echo $row['FullName']; ?>" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="phone">Phone No.</label>
<input type="tel" id="phone" name="phone" value="<?php echo $row['Phone_No']; ?>" pattern="[0-9]{10}" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="email">Email</label>
<input type="email" id="email" name="email" value="<?php echo $row['Email']; ?>" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="address">Address</label>
<input type="text" name="address" id="address" value="<?php echo $row['Address']; ?>" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="message">Message</label>
<textarea name="message" id="message" cols="30" rows="10" required autofocus autocomplete="off"><?php echo $row['Message']; ?></textarea>
</div>
<input type="hidden" name='Sr_No' value="<?php echo $row['Sr_No']; ?>">
<div class="input" id="field-submit">
<button type="submit" name="submit" id="btn">Update Message</button>
</div>
<div class="input">
<button type="submit" id="btn1"><a href="contact_details.php">Go Back</a></button>
</div>
</form>
</section>
</body>
</html>