Sweet Alert

The sweet alert function enables you to display alerts after actions have been done eg, after form submission you can display an error or success alert to the user

Structure

sweetAlert($title, $text, $type, $refresh = 'true', $redirect = '')

Parameters

The sweet alert function has 5 parameters as explained below

  • Title- This will be the title displayed on the alert

  • Text- This will be the body or description part of the alert

  • Type- This is the type of the alert values can either be: success, error, info, question, warning

  • Refresh - This is a string that accepts true or false. It is used to determine if the page will refresh after user clicks OK on the alert.

  • Redirect- This is an optional link that you can provide, if refresh is true, and you provide a link here, the user will be redirected to that link after they click OK on the sweet alert. If no redirect is provided and refresh is true, the current page will be refreshed.

Example Usage

echo sweetAlert('Booking Received','Your booking request has been successfully received','success','true');

Output

Sample sweet alert.

Last updated