-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_auction.php
More file actions
35 lines (29 loc) · 932 Bytes
/
edit_auction.php
File metadata and controls
35 lines (29 loc) · 932 Bytes
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
<?php
session_start();
if (!isset($_SESSION['email'])) {
header('Location: login.php');
exit();
}
$servername = "localhost";
$username = "root"; // Replace with your database username
$password = ""; // Replace with your database password
$dbname = "vehicle_auction";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$id = $_POST['id'];
$title = $_POST['title'];
$current_bid = $_POST['current_bid'];
$query = "UPDATE auctions SET title='$title', current_bid='$current_bid' WHERE id='$id'";
if (mysqli_query($conn, $query)) {
header('Location: user_auctions.php');
} else {
echo "Error updating record: " . mysqli_error($conn);
}
}
mysqli_close($conn);
?>