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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:38:11+00:00 2026-05-30T07:38:11+00:00

I have successfully setup an HTML form in PHP File #1, and it is

  • 0

I have successfully setup an HTML form in PHP File #1, and it is successfully posting the form data to PHP File #2. Now what I’m trying to do is take the posted data from PHP File #2 and store it as a variable in a new file, called PHP File #3. In this situation, the user will be submitting a search string through an input field, and all I want to do is use that information to be stored as a variable for later use in an external PHP file.

So let’s say the user submits “John Smith” through the input field. Right now, “John Smith” will get posted to PHP File #2 (it’s also turned into a variable there, called ‘$query’. So then I simply want to create the same variable in a 3rd PHP File (also called ‘$query’) and have the contents from the form be stored in it. But since it’s from an external source I don’t know the exact syntax on how to do this.

If someone could just show a generic example of this for pulling the info from the 2nd PHP file, that would be the most helpful. I’m pretty sure we would use file_get_contents, but I don’t understand how to pull a specific piece of info from a variable in the 2nd PHP file.

  • 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-30T07:38:12+00:00Added an answer on May 30, 2026 at 7:38 am

    One of the most common ways of handling this is to store the data you need in a session on page #2, and pull it from session on page #3.

    e.g. (barebones example)

    page 2

    <?php
    session_start();
    $query = isset($_POST['query']) ? trim($_POST['query']) : false;
    
    if (false === $query)
        throw new Exception('Missing query.');
    
    // Do whatever you need to with it.
    
    $_SESSION['query'] = $query;
    

    page 3

    <?php
    session_start();
    $query = isset($_SESSION['query']) ? $_SESSION['query'] : false;
    
    if (false === $query)
        throw new Exception('Missing query.');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to setup ELMAH to log errors for our application. I have successfully
Have anyone successfully managed to setup a combined Java/C++ project for Eclipse? What I
I have a .NET 3.5 Setup Package Project which installs my application successfully. The
I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008)
I have successfully compiled lua in my mac. It works. It runs. Now, I
I am trying to follow these instructions: http://source.android.com/source/downloading.html I have set up a fresh
I have successfully set up FILESTREAM on my SQL 2008 server; however I've noticed
I have successfully set up an HgWebDir instance over CGI with Apache, and I
I have successfully managed to get System.Speech.Synthesis to read English text in arbitrary voices
I have successfully implemented interop beftween Win32 application and managed .Net dll as described

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.