Edit User Email and Bio In PHP with MySQL

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

In this Blog, we are creating a code for editing user email and bio using PHP and MySQL

<?php 
//Connect to MySQL
$con = mysqli_connect("localhost","user","password","database");
// Check connection
if (mysqli_connect_errno()){
	echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

//update user email
$sql = "UPDATE users SET email = '[email protected]' WHERE id = '$user_id'";

if (!mysqli_query($con,$sql)) {
	die('Error: ' . mysqli_error($con));
}

//update user bio
$sql2 = "UPDATE users SET bio = 'This is my new bio' WHERE id = '$user_id'";

if (!mysqli_query($con,$sql2)) {
	die('Error: ' . mysqli_error($con));
}

//close connection
mysqli_close($con);
?>

Leave a Reply