0

I have a page to edit user information, I want to change the parameters that users have entered in edit user page, example: user wants to change email but other parameters will remain unchanged in the database.

$db->query("UPDATE users SET name='$name', username='$username', email='$email', password='$password_1' WHERE id='$id' ");

Could someone show me a way how to accomplish what I want?

function edit_info($id,$service)
{
    $db->query("UPDATE users SET '$service'= '$service'  WHERE id='$id' ");
}
Shadow
  • 33,525
  • 10
  • 51
  • 64
  • 1
    _..if there anyway that i could write a function like this ?..._ Well you have already written it. I don't get what is stopping you – B001ᛦ Oct 05 '20 at 19:59
  • 1
    yes you can but you wide open to **sql inejction** so use only **prepared statements with parameters** see https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – nbk Oct 05 '20 at 20:01

0 Answers0