updateEmail (function)

Last updated: Fri, May 26, 2023 10:32 am
Return to Knowledgebase


The updateEmail function in UserSpice is used to update the email address of a user in the database.




# Parameter Data Type Required Description
1 $id integer Yes The ID of the user to update.
2 $email string Yes The new email address for the user.


Data Type Description of Returned Data
bool Returns true if the update is successful, false otherwise.

Further Documentation:

// Update the email address of a user with ID 1
$userId = 1;
$newEmail = 'newemail@example.com';

$result = updateEmail($userId, $newEmail);

if ($result) {
echo "Email address updated successfully.";
} else {
echo "Failed to update email address.";

In the example above, the updateEmail function is called to update the email address of a user with ID 1 to 'newemail@example.com'. The function takes the user ID and the new email address as parameters and performs the necessary database update operation. The return value, $result, indicates whether the update operation was successful or not. Based on the result, an appropriate message is displayed to indicate the outcome of the email address update.