title: How to use sweetalert2 in php
body: <p>I have a code to insert data to MySQL which is working well, I want to replace the current java script alert to sweetalert2. I went through all forums but couldn't find anything.
  can anyone help me?
  Thank you.</p>
  
  <pre><code>&lt;?php
  //session_start();
  //include "dbcon.php";
  error_reporting(0);
  
  $conn = new PDO('mysql:host=localhost; dbname=fleet','root', 'root'); 
  
  $department=$_POST['department'];
  $employee=$_POST['employee'];
  $approver=$_POST['approver']; 
  $depart_date=$_POST['depart_date'];
  $return_date=$_POST['return_date'];
  $depart_time=$_POST['depart_time'];
  $return_time=$_POST['return_time'];
  $depart_place=$_POST['depart_place'];
  $arrival_place=$_POST['arrival_place'];
  $reason=$_POST['reason'];
  $request_timestamp=$_POST['request_timestamp'];    
  $approver_email = $_POST['approver_email'];
  //employee_name = $_POST['employee_name'];  
  $employee_name = $_POST['employee_name'];
  $approver_name = $_POST['approver_name'];
  $employee_title = $_POST['employee_title'];
  //$no_of_passengers = '';
  //$name_of_passengers = '';
  
  
  $no_of_passengers = $_POST['no_of_passengers'];
  $name_of_passengers = $_POST['name_of_passengers'];
  
  //$no_of_passengers2 = $_POST['no_of_passengers2'];
  //$name_of_passengers2 = $_POST['name_of_passengers2'];
  
  //$no_of_passengers2 = '';
  //$name_of_passengers2 = '';
  
  $sql2='';
  
  //include "mail.php";
  
  // $no_of_passengers2 = $_POST['no_of_passengers2'];
  // $name_of_passengers2 = $_POST['name_of_passengers2'];
  
  if (isset($_POST['submit'])) {
  
         // $sql2='';
  
          $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
          $sql = "INSERT INTO fms_booking_request (requested_by, approver, approving_dept, no_of_passengers, name_of_passengers, departure_place, arrival_place, reason, request_timestamp,departure_date, return_date, departure_time, return_time)
          VALUES ('$employee', '$approver', '$department', '$no_of_passengers', '$name_of_passengers', '$depart_place', '$arrival_place', '$reason','$request_timestamp','$depart_date', '$return_date','$depart_time','$return_time')";
  
          $conn-&gt;exec($sql);
          //$conn-&gt;exec($sql2);
  
          /*echo "&lt;br&gt;&lt;br&gt;You have successfully booked for a vehicle.&lt;br&gt;
                An emial is being sent to approver, Please wait for 5 seconds.&lt;br&gt;
                *&lt;br&gt;
                **&lt;br&gt;
                ***&lt;br&gt;
                ****&lt;br&gt;
                *****&lt;br&gt;
                ******&lt;br&gt;";
          */
          include "mail.php";
  
  
          echo "&lt;script&gt;alert('Successfully booked for a vehicle, email has been sent to approver'); window.location='vehicle_booking_form.php'&lt;/script&gt;";
  
  } 
  
  else{
  
      echo "&lt;script&gt;alert('Please try again!'); window.location='vehicle_booking_form.php'&lt;/script&gt;";
  }
  
  ?&gt;
  </code></pre>
  
  <p>I want to use this sweetalert</p>
  
  <pre><code>Swal.fire({
    position: 'top-end',
    type: 'success',
    title: 'Your work has been saved',
    showConfirmButton: false,
    timer: 1500
  })
  </code></pre>