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

  • SEARCH
  • Home
  • 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 8898511
In Process

The Archive Base Latest Questions

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

In my code below I am trying to retrieve the moduleid, use it to

  • 0

In my code below I am trying to retrieve the moduleid, use it to run a query in order to be able to find the module number and module name which belongs to that module id and then include session variables for the moduleid, module number and module name.

The problem I am having is that even though I am using (isset(), I am getting undefined index for $_SESSION['idmodule'] and ‘$_SESSION[‘namemodule’]. Now$_SESSION[‘module’]` is working fine, no problems with that session variable, but the other 2 session variables I am having problem with.

Now the query is correct so there is no problem wih the query, just the problem I am guessing on how I am trying to call the $_SESSION variables.

Below is the code:

if (isset($_POST['module']))
{
    $query = "SELECT ModuleNo, ModuleName FROM Module WHERE ModuleId = ?";

    $stmt = $mysqli->prepare($query);

    $stmt->bind_param('s', $_POST['module'] );

    $stmt->execute();

    $stmt->bind_result($moduleno, $modulename); 

     while ( $stmt->fetch() ) { 
           // session data
          if (isset($moduleno)){
          $_SESSION['idmodule'] = $moduleno;
      }
      if (isset($modulename)){
          $_SESSION['namemodule'] =  $modulename;
            }
    }

    $_SESSION['module'] = $_POST['module'];

}

.

  • 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:37:58+00:00Added an answer on June 15, 2026 at 12:37 am
    if (isset($moduleno)){
        $_SESSION['idmodule'] = $moduleno;
    }
    if (isset($modulename)){
        $_SESSION['namemodule'] =  $modulename;
    }
    

    Both those statements may prevent $_SESSION['idmodule'] or $_SESSION['namemodule'] to not be set, so when you reference them later you may get the warning.

    To prevent that, later in the code you may need this:

    if (isset($_SESSION['idmodule'], $_SESSION['namemodule']) {
        // your code here
    

    The beter way is to clean up a few things:

    while ( $stmt->fetch() ) {
        // inside here $moduleno and $modulename are already set
        $_SESSION['idmodule'] = $moduleno;
        $_SESSION['namemodule'] = $modulename;
    }
    

    If the module is not found, it would be best to skip the rest of the code and just show an error message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying retrieve user name from the code through graph api, the below
The code below is what I am trying to use in order to get
I am trying to retrieve the clicked object name through the code below, but
im trying to use the code below to select a form element (i retrieve
I am trying to retrieve information through Facebook graph api, using the below code
I am trying to retrieve DataTable from .xls file. Below are my code: OleDbConnection
I'm using the javascript code below trying to extract the number after gallery-entry_ in
I am trying to run the code below but it keeps locking up my
In the code snippet below I am trying to retrieve the RGB values of
I am trying to retrieve data form a dataset by using code below :

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.