I am trying to set up an exam page for my friend Neil. The user clicks on a link 'First Year exam' or 'Second Year exam' and goes to a login page. If the login is successful, and the time is right, the exam opens
I use this to make the exam page available at a certain time:
<?php
$time = date('Y:F:d:G:i');
echo 'the time now is ' . $time . '<br>';
// the page is only available between 10 and 11
if(date('G') < 10 or date('G') > 10 ) {
include 'jsclock.html';
exit();
}
?>
Works OK!
Now I would like to use PHP to open jsclock.html at 11 o'clock. I tried this at the top of the exam page:
echo "Welcome to the exam page</br>";
echo "we will redirect to the jsclock.html webpage in 30 seconds";
// The function will redirect to jsclock.html in 30 seconds
header("refresh: 30; url = jsclock.html");
exit();
But I get this message:
Welcome to the exam page we will redirect to the jsclock.html webpage in 30 seconds Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/Neil_Exam/FirstYear/19BEsW13.html.php:4) in /var/www/html/Neil_Exam/FirstYear/19BEsW13.html.php on line 7
The login.php will direct the user to the exam page if the login is successful:
//validate inputted password with $user password
if(password_verify($password, $user['password'])){
//action after a successful login
//for now just message a successful login
$_SESSION['success'] = 'User verification successful';
//header('location: 19BEsW13.html.php');
include '19BEsW13.html.php';
exit();
The login part also works well!
I do not use
'header('location: '19BEsW13.html.php');'
in login.php because I keep getting weird errors when I use
header('location ..
anywhere, so I use include statements.
Any tips on how to overcome this error please??
I could use javascript. I was told that it is 'trivial' to alter a webpage to change javascript settings. (Although I have no idea how!!) So I thought it is better to use php if I can.