Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8898879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:43:22+00:00 2026-06-15T00:43:22+00:00

i have written a php code… // If click check the session is set

  • 0

i have written a php code…

// If click check the session is set or not

if(isset($_POST['reserve'])){ if(!empty($_SESSION['username'])){
$db->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 }}

if session not start alert message should be displayed. how can i do it? i tried like this. but it didn’t work.

if(isset($_POST['reserve'])){
if(!empty($_SESSION['username'])){
$db->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”);

this is the link of bootbox site… http://bootboxjs.com/#usage

this is my full code

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Book Detail</title>
<link rel="stylesheet" href="../common/bootstrap/css/bootstrap.min.css" />
</head>

<body>
<?php


    // Run the query to get each books detail.
    $db->query("SELECT * FROM `book` WHERE `b_id` = '$book_id'");

    foreach($db->resultsArray as $row){
        echo "Id : ". $row['b_id'] . "<br />";
        echo "Category : ". $row['b_cat_id'] . "<br />";    
        echo "Title : ". $row['b_title'] . "<br />";    
        echo "Author : ". $row['b_author'] . "<br />";  
        echo "Summery : ". $row['b_summary'] . "<br />";    
    }

    // To get member id of loged in user's
    $db->query("SELECT `userId` FROM `user` WHERE `username` = '$username'");
    $userId = $db->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->query("INSERT INTO `reserve` (`r_b_id`,`r_m_id`,`r_date`) VALUES ('$book_id','$userId','$date')");

        }else{
            echo '<script type="text/javascript">$(document).load(function(){ bootbox.alert("You must login first");})</script>';
        }   
    }

?>
<form method="post" action="">
  <input type="submit" name="reserve" class="btn" id="reserve" value="Reserve Book" />
</form>

<!-- JS dependencies --> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script src="../common/bootstrap/js/bootstrap.min.js"></script> 

<!-- bootbox code --> 
<script type="text/javascript" src="https://raw.github.com/makeusabrew/bootbox/v2.4.2/bootbox.min.js"></script> 

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:43:24+00:00Added an answer on June 15, 2026 at 12:43 am

    try

    echo '$(document).load(function(){ bootbox.alert(“You must login first”);})';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple code in page test_cookie.php to work with cookies. if(isset($_GET['data']))
I have written a simple PHP code: <?php if (isset($_GET['day']) && isset($_GET['date']) && isset($GET['year']))
I have written PHP code which connects to MYSQL to look up information, sends
I have written a PHP function to take a video embed code that has
I have written a code for taking JSON data from a PHP and putting
I have written simple code to get content from xml file to php. $xml
I have to written the following code to send a mail using PHP in
Our website code is written in PHP. We have very little testing in regards
Possible Duplicate: jquery ajax return: undefined I have written the following code to check
I have written php code to retrieve data from database to div in webpage.i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.