I have couple of identical html
pages with forms and submit form button. When a form is sent, I redirect on a new page and I save a UNIX timestamp on a text file of when the form was sent, which also indicates when the user entered a new page all with PHP. The problem is on the last page I don't have a form and I don't know exactly how to get the timestamp.
PHP
:
if(isset($_POST['submit'])){
$t=time();
$myfile1 = fopen("temp/time.txt", "w");
fwrite($myfile1, $t.";
");
//and other not relevant operations
header("Location: main2.html");
}
if(isset($_POST['submit2'])){
$t=time();
$myfile1 = fopen("temp/time.txt", "w");
fwrite($myfile1, $t.";
");
//and other not relevant operations
header("Location: main3.html");
}
if(isset($_POST['submit3'])){
$t=time();
$myfile1 = fopen("temp/time.txt", "w");
fwrite($myfile1, $t.";
");
//and other not relevant operations
header("Location: main4.html");
}
if(isset($_POST['submit4'])){
$t=time();
$myfile1 = fopen("temp/time.txt", "w");
fwrite($myfile1, $t.";
");
//and other not relevant operations
header("Location: success.html");
}
So, the problem is that I cannot do if(isset($_POST['...'])){
because I don't have a form on the success.html. So is there a way to get the UNIX timestamp, in order to know when the user entered the last page or alternatively left the previous one?
Thank you in advance and I do apologize if the question is too easy.
I'd avoid to repeat the same code again and again
//this will happen every time i run this php
$t=time();
$myfile1 = fopen("temp/time.txt", "w");
fwrite($myfile1, $t.";
");
//and other not relevant operations
//this only if isset one of the submit
if(isset($_POST['submit'])){
header("Location: main2.html");
}
if(isset($_POST['submit2'])){
header("Location: main3.html");
}
if(isset($_POST['submit3'])){
header("Location: main4.html");
}
if(isset($_POST['submit4'])){
header("Location: success.html");
}
So you will store the date every time you get to this php page. Then, if it is necessary based on your conditions you will be redirected