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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:39:23+00:00 2026-06-02T13:39:23+00:00

How can I store a PHP variable in a PHP script, and then use

  • 0

How can I store a PHP variable in a PHP script, and then use that same variable in an another PHP script?

I tried this code, but it didn’t work:

<?php                       
                    session_start();
                            $util=$_POST['util'];
                            $pw=$_POST['pw'];
                            include("abrebdvendas.php");
                            //testar a exist�ncia de liga��o ao MySQL
                            $ligax=mysql_connect($host,$user,$senha);
                            if (!$ligax) {
                                    echo 'Erro: Falha na liga&#231;&#227;o'.'<br>';
                                    exit;
                                    }
                                    //ligar � base de dados vendas
                                    mysql_select_db($dbname,$ligax);
                                    //criar uma query para inser��o do registo
                                    $lista="select * from utilizador where util='$util' and pw='$pw'";
                                    $result=mysql_query($lista) or die(mysql_error());
                                    $dados = mysql_fetch_array($result);
                                    $u=$dados['util'];
                                    $p=$dados['pw'];
                            if ($u=='' or $p=='')
                            {
                            echo "Tente de novo";
                            echo '<meta HTTP-EQUIV="Refresh" CONTENT="1; URL=http://localhost/ola1/Site/Sem%20Log%20In/longin.html">';
                            } 
                            else if ($u==$util and $p==$pw)
                                    {
                                    //obter tipo valor
                                    echo '<h2>Bem vindo '.$util.'</h2><br>';
                                    $paulo=$_POST['util'];
                                    echo '<meta HTTP-EQUIV="Refresh" CONTENT="100; URL=http://localhost/ola1/Site/Com%20LogIn/paginicial.php">';

                                     $_SESSION['myNumber']=$num;                
                                                                        }
                                    else
                                    {
                                    echo "Tente de novo";
                                    echo '<meta HTTP-EQUIV="Refresh" CONTENT="0.1; URL=http://localhost/ola1/Site/Sem%20Log%20In/longin.html">';
                                    }                                   
                    ?>

The code is from here.

  • 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-02T13:39:26+00:00Added an answer on June 2, 2026 at 1:39 pm

    when you want to use value of some variable which is stored in another variable in another page ,you should use $_SESSION[] as below:

     $_SESSION['myNumber']=$num;
    

    You need to start session at the top of the php page as below:

     <?php
    ob_start();
    @session_start();
    ?>
    

    And get variable from another php file as below

    $newnum = $_SESSION['myNumber'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store php code inside my database and then use it into
I just want to ask if there is any PHP/MySQL datatype that can store
I use settings.php to store general settings for my application. When I load this
Hopefully this makes sense. I have a php script, magpierss, that parses a RSS
I am trying to create a php array where I can store 2 variables
According to the PDO documentation , you can store database login details in php.ini,
I have a maintenance script in PHP that updates and repairs the database. In
I have an email template that is inside a PHP script. I am using
I am trying to write a PHP script that will create an HTML form
In my website I've a php script that launches a file download without showing

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.