there is such code here:

<form method="POST"> <input type="text" name="first" /> <input type="submit" name="ok_go" value="GO" /> </form> <?php if(isset($_POST['ok_go'])){ $first_var = $_POST['first']; $first_var = trim($first_var); if(empty($first_var)) echo 'Пусто'; else { echo 'Вы ввели: <b>', $first_var, '</b>'; } } ?> 

I enter the text into the page, it shows you entered (my text) here only after a restart through another browser does not save what I entered. How to make so that the text I entered is preserved even after the page is updated?

    3 answers 3

     <?php $first_var = null; if(isset($_POST['ok_go'])){ $first_var = $_POST['first']; $first_var = trim($first_var); if(empty($first_var)) echo 'Пусто'; else { echo 'Вы ввели: <b>', $first_var, '</b>'; } } ?> <form method="POST"> <input type="text" name="first" value="<?= $first_var ?>" /> <input type="submit" name="ok_go" value="GO" /> </form> 
    • You should add a few words at least .. For example, that php should be added before the form, at least. - entithat
    • It does not work, in another browser does not show anything - k1ceargy
     <?php session_start(); $first_var = null; if(isset($_POST['ok_go'])){ $first_var = $_POST['first']; $first_var = trim($first_var); if(empty($first_var)) { echo 'Пусто'; } else { $_SESSION['var'] = $first_var; echo 'Вы ввели: <b>', $first_var, '</b>'; } } ?> <form method="POST"> <input type="text" name="first" value="<?= isset($_SESSION['var']) ? $_SESSION['var'] : '' ?>" /> <input type="submit" name="ok_go" value="GO" /> </form> 
    • from another browser does not save does not show the entered text - k1ceargy
    • and from another browser it will not show you) how do you imagine it yourself? - madfan41k
    • to display in another browser, you need to write the result somewhere, to a file or database, then read it and output it) - madfan41k
    • I do not rummage in php, so I ask. - k1ceargy
    • Well, actually you have the answer) - madfan41k

    Do not do it. All authorization is based on the fact that the browser "remembers" you. In the browser there are cookies - this is such a data warehouse, in which you can give a write command from the server. In the next request, the browser will send you the information that you told him to save. So you will understand which user you are dealing with.

    You can show a special link on one browser by copying it and pasting it in another browser, it will be able to log in. But it is not very safe.