title: how to display alert box with Bootbox js plugin
body: <p>i have written a php code…</p>
  
  <p>// If click check the session is set or not</p>
  
  <pre><code>if(isset($_POST['reserve'])){ if(!empty($_SESSION['username'])){
  $db-&gt;query(“INSERT INTO `reserve` (`r_b_id`,`r_m_id`,`r_date`) VALUES 
  (‘$book_id’,'$userId’,'$date’)”);
  }else{
  echo ‘ ‘; // I nee to display alert box here }}
  </code></pre>
  
  <p>if session not start alert message should be displayed. how can i do it? i tried like this. but it didn’t work.</p>
  
  <pre><code>if(isset($_POST['reserve'])){
  if(!empty($_SESSION['username'])){
  $db-&gt;query(“INSERT INTO `reserve` (`r_b_id`,`r_m_id`,`r_date`) VALUES         (‘$book_id’,'$userId’,'$date’)”);
  }else{
  echo ‘$(document).load(function(){
  bootbox.alert(“You must login first”);
  </code></pre>
  
  <p>this is the link of bootbox site... <a href="http://bootboxjs.com/#usage" rel="nofollow">http://bootboxjs.com/#usage</a></p>
  
  <p>this is my full code</p>
  
  <pre><code>   &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Book Detail&lt;/title&gt;
  &lt;link rel="stylesheet" href="../common/bootstrap/css/bootstrap.min.css" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  
  
      // Run the query to get each books detail.
      $db-&gt;query("SELECT * FROM `book` WHERE `b_id` = '$book_id'");
  
      foreach($db-&gt;resultsArray as $row){
          echo "Id : ". $row['b_id'] . "&lt;br /&gt;";
          echo "Category : ". $row['b_cat_id'] . "&lt;br /&gt;";    
          echo "Title : ". $row['b_title'] . "&lt;br /&gt;";    
          echo "Author : ". $row['b_author'] . "&lt;br /&gt;";  
          echo "Summery : ". $row['b_summary'] . "&lt;br /&gt;";    
      }
  
      // To get member id of loged in user's
      $db-&gt;query("SELECT `userId` FROM `user` WHERE `username` = '$username'");
      $userId = $db-&gt;resultsArray['0']['userId'];
  
      // Get system date
      $date = date("Y-m-d");
  
      // Check reserve book button
      // If click check the session is set or not
      if(isset($_POST['reserve'])){
          if(!empty($_SESSION['username'])){
  
              $db-&gt;query("INSERT INTO `reserve` (`r_b_id`,`r_m_id`,`r_date`) VALUES ('$book_id','$userId','$date')");
  
          }else{
              echo '&lt;script type="text/javascript"&gt;$(document).load(function(){ bootbox.alert("You must login first");})&lt;/script&gt;';
          }   
      }
  
  ?&gt;
  &lt;form method="post" action=""&gt;
    &lt;input type="submit" name="reserve" class="btn" id="reserve" value="Reserve Book" /&gt;
  &lt;/form&gt;
  
  &lt;!-- JS dependencies --&gt; 
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; 
  &lt;script src="../common/bootstrap/js/bootstrap.min.js"&gt;&lt;/script&gt; 
  
  &lt;!-- bootbox code --&gt; 
  &lt;script type="text/javascript" src="https://raw.github.com/makeusabrew/bootbox/v2.4.2/bootbox.min.js"&gt;&lt;/script&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>