I'm doing a small application where the user registers some data and I want the user to be registered in the registry but I can not get it.
1.- The user starts session (login.php) and I have a hidden form that sends the username to another POST file
echo "Bienvenido $username
<form action='add_retiro.php' method='post'>
<input type='hidden' class='form-control' id='username' name='username'
value='$username' required>
<input type='submit' value='Empezar'/>
";
2.- The 2nd file receives the username (add_registro.php)
<?php
$time = time();
$username = $_POST['username'];
session_start();
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
} else {
echo "Inicia Session<br>";
echo "<br><a href='http://web.xyz/index.html'>Login</a>";
exit;
}
$now = time();
$fechaguardada = $_SESSION["expire"];
$tiempo_transcurrido = $now-$fechaguardada;
if($tiempo_transcurrido >= 60000) {
session_destroy();
header('Location: http://web.xyz/index.html');
exit;
}
?>
<html>
<form action="add_retiro1.php" method="post"><h2>Deposito de Retiros</h2>
<input class="large" type="number" id="inputtext2" name="inputtext2"
placeholder="Escribe el Numero de Retiro" required/>
<input class="large" type="number" id="inputnumber1" name="inputnumber1"
placeholder="Escribe el Monto del Retiro" required/>
<input type="hidden" class="form-control" id="inputtext3" name="inputtext3"
value="<?php echo $username ?>" placeholder="Nombre de Usuario" required />
<input type="hidden" class="form-control" id="inputtext4" name="inputtext4"
value="<?php echo date("d-m-Y (H:i:s)", $time -18000); ? >"
placeholder="Hora y Fecha" required />
<input type="submit" value="Enviar"/></div>
</form>
This registers correctly in the bd After registration the php file that does the insert function in the db redirects to the file add_registro.php
But when recapturing another record the User appears blank because $ username = $ _POST ['username']; IT DOES NOT HAVE VALUE since it was a redirection
WHAT SOLUTION DO YOU RECOMMEND ME?
open some way to get the username of the session to use it in any file?
Helppppp ......