title: How to open Bootstrap modal by using a PHP GET request?
body: <p>I search but I didn't find any solution for this. I need to create a modal like this.</p>
  
  <p>When we pass <strong>true</strong> in <strong>GET</strong> request the modal must be shown. Otherwise if not any value for $GET request page will be load normally.</p>
  
  <p>I am trying to do this by:</p>
  
  <pre><code> &lt;?php if(isset($_GET["model"=="true"])){
            echo "
              &lt;script type='text/javascript'&gt;
              $(document).ready(function(){
              $('#addstudent').modal('show');
              });
              &lt;/script&gt;" ;
           } ?&gt;
  </code></pre>
  
  <p>But it didn't work with my code.</p>
  
  <p>Full code:</p>
  
  <pre><code>&lt;?php 
      include_once('../func/islogin.php') ;
    if($login=='false'){
        header('location:../index.php');
    }elseif($login!='true'){
      header('location:../index.php');
    }
  
    include('../include/conn.php') ;
  
    ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template"&gt;
      &lt;meta name="author" content="GeeksLabs"&gt;
      &lt;link rel="shortcut icon" href="img/favicon.png"&gt;
      &lt;title&gt;SMS - Sending System&lt;/title&gt;
      &lt;script src="https://kit.fontawesome.com/e491dc23d1.js" crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;link href="../css/bootstrap.min.css" rel="stylesheet"&gt;
      &lt;link href="../css/bootstrap-theme.css" rel="stylesheet"&gt;
      &lt;link href="../css/elegant-icons-style.css" rel="stylesheet"/&gt;
      &lt;link href="../css/font-awesome.min.css" rel="stylesheet" /&gt;
      &lt;link href="../css/style.css" rel="stylesheet"&gt;
      &lt;link href="../css/style-responsive.css" rel="stylesheet" /&gt;
    &lt;/head&gt;
     &lt;body&gt;
          &lt;?php if(isset($_GET["model"=="true"])){
            echo "
              &lt;script type='text/javascript'&gt;
              $(document).ready(function(){
              $('#addstudent').modal('show');
              });
              &lt;/script&gt;" ;
           } ?&gt;
       &lt;section id="container" class=""&gt;
         &lt;header class="header dark-bg"&gt;
           &lt;div class="toggle-nav"&gt;
             &lt;div class="icon-reorder tooltips" data-original-title="Toggle Navigation" data-placement="bottom"&gt;&lt;i class="icon_menu"&gt;&lt;/i&gt;&lt;/div&gt;
            &lt;/div&gt;
            &lt;a href="index.php" class="logo"&gt;SFT &lt;span class="lite"&gt;හසිත පෙරේරා&lt;/span&gt;&lt;/a&gt;
          &lt;/div&gt;
        &lt;/header&gt;  &lt;!--header menu end--&gt;
         &lt;?php include('../include/design/slidebar.php') ?&gt; &lt;!--sidebar Include--&gt;
        &lt;/div&gt;
       &lt;/aside&gt;
  
      &lt;section id="main-content"&gt;
        &lt;section class="wrapper"&gt;
  
          &lt;div class="row"&gt;
            &lt;div class="col-lg-12"&gt;
              &lt;h3 class="page-header"&gt;&lt;i class="fas fa-chalkboard-teacher"&gt;&lt;/i&gt; Classes&lt;/h3&gt;
            &lt;/div&gt;
               &lt;?php include('../include/design/statusbar.php') ?&gt;
          &lt;/div&gt;
  
           &lt;div class="row"&gt;
             &lt;div class="col-lg-8"&gt;
               &lt;section class="panel"&gt;
                &lt;header class="panel-heading text-center"&gt;
                  List Of All Classes
                &lt;/header&gt;
              &lt;table class="table table-striped  table-advance table-hover"&gt;
                &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;th&gt;&lt;i class="fas fa-sort-amount-down"&gt;&lt;/i&gt;&lt;/i&gt; Class_ID&lt;/th&gt;
                      &lt;th&gt;&lt;i class="fas fa-building"&gt;&lt;/i&gt; Class_Name&lt;/th&gt;
                      &lt;th&gt;&lt;i class="fas fa-sync-alt"&gt;&lt;/i&gt;&lt;/i&gt; Status&lt;/th&gt;
                      &lt;th&gt;&lt;i class="fas fa-user-edit"&gt;&lt;/i&gt; Manage&lt;/th&gt;
                      &lt;th&gt;&lt;i class="icon_cogs"&gt;&lt;/i&gt; Action&lt;/th&gt;
                  &lt;/tr&gt;
                          &lt;?php 
                          $alldonators="SELECT * FROM classes ";
                          $alldonators_query = mysqli_query($conn,$alldonators);
                          if($alldonators_query){
                              while($row=mysqli_fetch_assoc($alldonators_query)){ ?&gt;
                   &lt;tr&gt;
                      &lt;td&gt;&lt;?php echo $row['id'] ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['Class'] ?&gt;&lt;/td&gt;
                      &lt;td&gt;
                        &lt;span
                            &lt;?php if($row['isActive'] == 1){
                                 echo " class='text-success'&gt; &lt;i class='icon_check_alt2'&gt;&lt;/i&gt; Active ";
                                } else{
                                  echo " class='text-danger' &gt;&lt;i class='fas fa-exclamation-circle'&gt;&lt;/i&gt; Inactive";
                                }?&gt;
                        &lt;/span&gt;
                      &lt;/td&gt;
                      &lt;td&gt;&lt;div class="btn btn-primary"&gt;&lt;i class="fas fa-user-edit"&gt;&lt;/i&gt; Manage Class&lt;/div&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;div class="btn-group"&gt;
                         &lt;?php if($row['isActive'] == 1){
                                 echo "&lt;a class='btn btn-warning' href='#'&gt;&lt;i class='fas fa-exclamation-circle'&gt;&lt;/i&gt; &lt;/a&gt;";
                                } else{
                                   echo "&lt;a class='btn btn-success' href='#'&gt;&lt;i class='icon_check_alt2'&gt;&lt;/i&gt; &lt;/a&gt;";
                                }?&gt;
                          &lt;a class="btn btn-danger" href="#"&gt;&lt;i class="icon_close_alt2"&gt;&lt;/i&gt;&lt;/a&gt;
                          &lt;/div&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;     
                      &lt;?php  } } ?&gt;
                  &lt;/tbody&gt;
                 &lt;/table&gt;
                &lt;/section&gt;
               &lt;/div&gt;
  
  
            &lt;div class="col-lg-4"&gt;
              &lt;button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addstudent"&gt;
                &lt;i class="fas fa-plus-circle"&gt;&lt;/i&gt; Create New Class
              &lt;/button&gt;
               &lt;div class="modal fade" id="addstudent" tabindex="-1" role="dialog" aria-labelledby="addstudents" aria-hidden="true"&gt;
                &lt;div class="modal-dialog" role="document"&gt;
                  &lt;div class="modal-content"&gt;
                     &lt;div class="modal-header"&gt;
                        &lt;h5 class="modal-title" id="addstudent"&gt;Add Student-Class&lt;/h5&gt;
                     &lt;/div&gt;
                      &lt;div class="modal-body"&gt;
                        &lt;form action="../func/saveclass.php" method="POST"&gt;
                              &lt;!--  Input Name --&gt;
                              &lt;div class="form-group"&gt;
                                &lt;label for="ClassNameInput" required&gt;Name For Class&lt;/label&gt;
                                &lt;textarea class="form-control" id="ClassNameInput" name="newclassInput" placeholder ="2020 A/L Matugame" rows="3" required&gt;&lt;/textarea&gt;
                              &lt;/div&gt;
                              &lt;!--  input current Status --&gt;
                                &lt;div class="form-group"&gt;
                                    &lt;label for="InputCurrentStatus"&gt;Current Status&lt;/label&gt;
                                      &lt;select class="form-control" id="InputCurrentStatus" name="statusInput"&gt;
                                        &lt;option value="1"&gt;Active&lt;/option&gt;
                                        &lt;option value="0"&gt;Inactive&lt;/option&gt;
                                      &lt;/select&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;
                          &lt;!-- modal-footer --&gt;
                          &lt;div class="modal-footer"&gt;
                            &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;Close&lt;/button&gt;
                            &lt;button type="submit" class="btn btn-primary" name="saveClassBtn"&gt;Save changes&lt;/button&gt;
                           &lt;/form&gt;
                        &lt;/div&gt;
                       &lt;/div&gt;
                      &lt;/div&gt;
                     &lt;/div&gt;
                    &lt;/div&gt;
                   &lt;/div&gt;
                  &lt;/div&gt;
                 &lt;/section&gt;
                 &lt;/section&gt;
                &lt;/section&gt;
  
  
  
  
    &lt;!-- container section end --&gt;
    &lt;!-- javascripts --&gt;
    &lt;script src="../js/jquery.js"&gt;&lt;/script&gt;
    &lt;script src="../js/bootstrap.min.js"&gt;&lt;/script&gt;
    &lt;!-- nice scroll --&gt;
    &lt;script src="../js/jquery.scrollTo.min.js"&gt;&lt;/script&gt;
    &lt;script src="../js/jquery.nicescroll.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;!--custome script for all page--&gt;
    &lt;script src="../js/scripts.js"&gt;&lt;/script&gt;
  
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>