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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:05:24+00:00 2026-06-04T19:05:24+00:00

here’s a question : After entering some data about students, i need to print

  • 0

here’s a question : After entering some data about students, i need to print them in top side of the page (form one). I’ve managed to print data for single student, but i can’t make it to store data in $studenti array, so that it will print data for all students.
here’s code that i used(i forgot to mention, i need to use sessions for this):

    <?php
session_start();

$_SESSION['aindex'] = $_POST['index'];
$_SESSION['aime']= $_POST['ime'];
$_SESSION['aprosek'] = $_POST['prosek'];

//if ($index != "" && $ime != "" && $prosek !="")
//{
// = $index;
 //= $ime;
 //=$prosek;

//}

//print ($_SESSION['aindex']);
function inicijalizacija()
{
    $studenti = array ();
    $ind = $_SESSION['aindex'];
    $im = $_SESSION['aime'];
    $pr = $_SESSION['aprosek'];

    $studenti[$ind]["ime"] = $im;
    $studenti[$ind]["prosek"] = $pr;

return $studenti;   
}

function dodaj($studenti)
{
$studenti[$_SESSION['aindex']]["ime"] = $_SESSION['aime'];
$studenti[$_SESSION['aindex']]["prosek"] = $_SESSION['aprosek'];

return $studenti;
}

function prikazi($studenti) //ovde u argumentu treba $studenti
{

print ("<h2> Lista Studenata: </h2>");
foreach ($studenti as $ind => $student)
{
if (empty($ind))
    continue;
$n = $student["ime"];
$p = $student["prosek"];
print ("Index: " . $ind . " " . "Ime: " . $n . " " .  "Prosek: " . $p );


}
print("<hr size ='1'>");

//Forma dodavanja

print (" <form action = 'index.php' method = 'post' >");
print ( " Indeks:&nbsp   <input type = 'text' name = 'index' />");
print(" </br>");
print ( " Ime:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp   <input type = 'text' name = 'ime' >");
print(" </br>");
print ( " Prosek : <input type = 'text' name = 'prosek' />");
print(" </br>");
print (" <input type = 'submit' value = 'Dodaj' name = 'Dodaj' />");
}




$studenti = inicijalizacija();
?>


<html>
    <head> <title> pokusaj </title> </head>
    <body>
    <?php

    prikazi($studenti);
    dodaj($studenti);
    ?>

    </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-04T19:05:25+00:00Added an answer on June 4, 2026 at 7:05 pm

    It seems you’re misunderstanding the way PHP works. For efficiency and security, all variables are destroyed when the script has ran and the variables used for this user aren’t visible for the script when called by other users.

    $_SESSION is an exception; data in $_SESSION will be preserved until the session expires, but it will still only be visible to one unique user (identified by a cookie).

    If you want to save the data of a script for use when it is called again (using another session), you’ll have to write data to a file or use a database.

    PS, your script looks like it will introduce XSS and CSRF vulnerabilities; make sure you won’t make the same mistakes that many people before you made.

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

Sidebar

Related Questions

Here is a scenario: User installs .NET application that you have made. After some
Here's some CSS and HTML to make a textarea below a list of data
Here's the basic setup: I have a thin bar at the top of a
Here is my code (Say we have a single button on the page that
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here a simple question : What do you think of code which use try
Here is my question. I am having this simple menu. <div id=menu> <ul> <li>
Here is an example of what I need http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html I need interactive list to
Here's my situation: I have a Data Template set up which contains a ToggleButton
Here's the thing: I want to add some images programmatically. The images should have

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.