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 7639191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:21:24+00:00 2026-05-31T08:21:24+00:00

Is it possible to use a POST variable on the buffered script? The code

  • 0

Is it possible to use a POST variable on the buffered script? The code is the following

<?php
header('Content-type: application/json');

$someVar= $_POST["var"];

ob_start();
require "someScript.php?var=" . $someVar; // instead of passing through GET, is there a way to use the $someVar directly?
$output = ob_get_clean();
echo $output;
?>

Note: I’ve already tried to access $someVar directly from someScript but without success. For that is why I’m asking. Thanks

EDIT: Possible someScript.php

<?php
    header('Content-type: application/json');
    require_once("BD.php");
    require_once("json/json_header.php");
    require_once("tools.php");
    require_once('class.phpmailer.php');

    $BD = new BDInfo(); 


    function encodeIDs($id1,$id2){

        // doesn't matter
    }

    $response = array("errorCode" => 0, "errorDesc" => "No Error");


    if(isset($someVar)){
        try{
            $link = mysqli_connect($BD->BDServer, $BD->BDUsername, $BD->BDPassword);

            if( !$link )
                throw new Exception( "..." );

            if( !mysqli_select_db($link, $BD->BDDatabase) )
                throw new Exception( "..." );

            $SQL="SELECT (...) us.VAR='" . $someVar . "';";

            $RS = mysqli_query($link,$SQL);
            if($RS && $row = mysqli_fetch_array($RS)){
                // process query result
            }
            else
            {
                $response["errorCode"]=4;    
                $response["errorDesc"]="Error descr";   
            }
            mysqli_close($link);

        }catch (Exception $e) {
            $response["errorCode"]=1;
            $response["errorDesc"]="Database Error: " . $e->getMessage();
        }
    }else{
        $response["errorCode"]=2;
        $response["errorDesc"]="Invalid Parameters";
    }

    echo json_encode($response);
?> 

I get Invalid Parameters, showing that isset($var) failed

  • 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-05-31T08:21:25+00:00Added an answer on May 31, 2026 at 8:21 am

    The variable $someVar is already available to you in someScript.php. You should not use a query string to do transfer it.

    If you want to avoid modifying someScript.php for some reason then you can do this:

    $_GET['var'] = $someVar; 
    

    Or just this:

    $_GET['var'] = $_POST['var'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code multiple times: $.ajax({ type: POST, cache: false, url: url
Possible Duplicate: Troubles with a PHP session variable after form submission I use sessions
Is it possible to use a session variable, then unset it directly after? Example:
Getting variable from form: <form method = 'POST' action = ''> <input type =
With the code below is possible to get separate values, using the variable data
Possible Duplicate: Can't decode JSON string in php I'm at my wits end here,
Is it possible to do a cURL post with PHP that will post my
Is it possible use mod_rewrite to resolve addresses hosted on another server? Say I
I have recently started looking into Google Charts API for possible use within the
Possible Duplicate: Use SVN Revision to label build in CCNET I'm working through the

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.