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 $ENVDBHOST';
$port $ENVDBPORT';
$username $ENVDBUSERNAME';
$password $ENVDBPASSWORD';
$dbname $ENVDB;
Create connection
$thisconn new mysqli$servername, $username, $password, $dbname;
Check connection
if $thisconnconnecterror
dieConnection failed: $thisconnconnecterror;
public function getConnection
return $thisconn;
public function closeConnection
$thisconnclose;
profileupdate.php:
query$sql;
$row $resultfetchassoc;
If the form is submitted
if $SERVERREQUESTMETHOD" "POST"
Get the new profile data from the form
$firstname $POSTfirstname;
$lastname $POSTlastname;
$mobilenumber $POSTmobilenumber;
$email $POSTemail;
Update the user's profile in the database
$sql "UPDATE Users SET firstname$firstname', lastname$lastname', mobilenumber$mobilenumber', email$email' WHERE id$id;
if $connquery$sql TRUE
echo "Profile updated successfully";
else
echo "Error updating profile: $connerror;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
