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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:19:07+00:00 2026-06-15T14:19:07+00:00

i’m sending session values from my first.php and trying to get from my second.php.

  • 0

i’m sending session values from my first.php and trying to get from my second.php. I have done some reading about this, and works fine on my localhost, but on my server doesn’t work at all.

Here is the code from my first.php file:

<?php
session_start();
ob_start();
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="http://localhost/Shopping_biblioteka/css/style.css">
        <title></title>
    </head>
    <body align="center">
        <div id="login">
        <?php

        if (isset($_POST['username']) && isset($_POST['password'])) {
            $username = $_POST['username'];
            $password = $_POST['password'];
            mysql_connect("localhost", "shopping_katalog", "logik@112233") or die(mysql_error());
            mysql_select_db("shopping_katalog") or die(mysql_error());
        mysql_query("SET CHARACTER SET utf8");
        mysql_query("SET NAMES utf8");
            $result = mysql_query("SELECT password,id FROM x9qg6_users
            where username='" . $username . "'");
            if (!$result) {
                echo 'Could not run query: ' . mysql_error();
                exit;
            }
            $row = mysql_fetch_row($result);

            $userhash = md5($password . $test[1]);

            if ($test[0] === $userhash) {
                $_SESSION['login_user'] = $user_id;
                $_SESSION['username'] = $username;
                $url = "biblioteka.php";
                header("Location: $url");
            }
        } else {
            echo 'Внесете ги вашите податоци во полињата!';
        }
        ?> 
        <form action="" method="POST" accept-charset="UTF-8"> 
            Корисничко име:<br/>
            <input name="username" id="username" type="text"/><br/>
            Лозинка:<br/>
            <input type="password" id="password" name="password"/><br/>
            <input type="submit" value="Логирај се!"/>
        </form>

        </div>
    </body>
</html> 

And here is my second.php file:

<?php
session_start();

?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="http://localhost/Shopping_biblioteka/css/style.css">
        <title>Библиотека на</title>
    </head>
    <body>
        <div id="wrapper">
            <?php

            $user_ID = $_SESSION['login_user'];
            $logged_user = $_SESSION['username'];
            ?>
            <h1 align="center" id="b_welcome">Добредојде <?php echo $logged_user; ?> во твојата библиотека! </h1>
            <h4 align="center" id="b_info">Во твојата библиотека ги имаш следниве книги</h4>
            <div id="knigi">
                <?php
                /* OVA E QUERITO
                 * 
                  SELECT *
                  FROM Knigi k, poracki p
                  WHERE k.knigaid = p.kniga
                  AND p.korisnikInt = $user_ID
                 * 
                 */

//-----------------------------------

                if(isset($_SESSION['login_user'])){
                mysql_connect("localhost", "user", "pass) or die(mysql_error());
                mysql_select_db("shopping_katalog") or die(mysql_error());
        mysql_query("SET CHARACTER SET utf8");
        mysql_query("SET NAMES utf8");
                $result = mysql_query("SELECT * FROM Knigi k, poracki p
        WHERE k.knigaid = p.kniga AND p.korisnikInt ='" . $user_ID . "'");
                while ($row = mysql_fetch_array($result)) {

//knigaid,naslov,avtor,link_do_pdf,thumb_link,kategorija,cena,br_strani
                    echo '<div id="item">';
                    echo '<a href="http://' . $row['link_do_pdf'] . '"><h5 align="center" id="b_item_title">' . $row['naslov'] . '</h5></a>';
                    //echo '<a href="http://' . $row['link_do_pdf'] . '">' . $row['avtor'] . '</a>';
                    echo '<a href="http://' . $row['link_do_pdf'] . '"><img src="http://' . $row['thumb_link'] . '" id="b_item_slika" /></a>';
                    echo '</div>';

                }

                if (!$result) {
                    echo 'Проблем со добивање на податоците: ' . mysql_error();
                    exit;
                }
                }else{
                    $url = "/index.php";
                header("Location: $url");
                }
                ?>
            </div><!--kraj na knigite-->
        </div>
    </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-15T14:19:08+00:00Added an answer on June 15, 2026 at 2:19 pm

    Here is the concept:

    in you first_page.php the user should enter his username and password and if you find them both are correct and match those exist in the database, then you will set a session and store whatever data you want in it, then you will redirect the user to the second_page.php which will use those session stored values to do whatever you want with them. And if the user didn’t enter his username and password he will stay in the first_page.php

    And here is a simple example from which you can take the main concept and apply it on your case:

    in first_page.php

    <?php
    session_start();
    ob_start();
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
        </head>
        <body align="center">
            <div>
                <?php
                    if (!empty($_POST["username"]) && !empty($_POST["password"])) {
                        $_SESSION['username'] = $_POST["username"];
                        header("Location: second_page.php");
                    }
                ?> 
                <form action="first_page.php" method="post" accept-charset="UTF-8"> 
                    Username: <input type="text" name="username" /><br/>
                    Password: <input type="password" name="password"/><br/>
                    <input type="submit" value="Login"/>
                </form>
            </div>
        </body>
    </html>
    

    And in second_page.php

    <?php
    session_start();
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title></title>
        </head>
        <body>
            <h3>Welcome <?php echo $_SESSION["username"] ?></h3>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.