Question: I need help updating user profile in PHP . DBconnection.php: load ( ) ; / / Database configuration $servername = $ _ ENV [ '

I need help updating user profile in PHP.
DBconnection.php:
load();
// Database configuration
$servername = $_ENV['DB_HOST'];
$port = $_ENV['DB_PORT'];
$username = $_ENV['DB_USER_NAME'];
$password = $_ENV['DB_PASSWORD'];
$dbname = $_ENV['DB'];
// Create connection
$this->conn = new \mysqli($servername, $username, $password, $dbname);
// Check connection
if ($this->conn->connect_error){
die("Connection failed: ". $this->conn->connect_error);
}
}
public function getConnection(){
return $this->conn;
}
public function closeConnection(){
$this->conn->close();
}
}
profile_update.php:
query($sql);
$row = $result->fetch_assoc();
// If the form is submitted
if ($_SERVER["REQUEST_METHOD"]== "POST"){
// Get the new profile data from the form
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$mobilenumber = $_POST['mobilenumber'];
$email = $_POST['email'];
// Update the user's profile in the database
$sql = "UPDATE Users SET firstname='$firstname', lastname='$lastname', mobilenumber='$mobilenumber', email='$email' WHERE id='$id'";
if ($conn->query($sql)=== TRUE){
echo "Profile updated successfully";
} else {
echo "Error updating profile: ". $conn->error;
}
}
?>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!