I’d like to force my code to pause after completion and before displaying a completion message. I’ve tried sleep and wait commands but they affect the start of running the code. I’ve searched the web for how to do this for two days with no success. Tried usleep() and the page wouldn’t even load. The reason for wanting the delay before showing the completion message is that the code processes so quickly that the completion message appears as soon as the page shows on the computer. I’d appreciate some help on this. Here’s my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
<title>Foxclone backup, restore, and cloning utility</title>
<meta name="description" content= "FoxClone is a Linux based image backup, restore and clone tool using a simple point and click interface." />
<link rel="stylesheet" type="text/css" media="screen" href="css/update.css">
<!-- Favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="images/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
<link rel="mask-icon" href="images/favicon/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<div class="container">
<div class="row" style="text-align:center;" >
<h1>Foxclone Filelist Updating</h1>
</div>
<div class="header">
</div>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$php_scripts = '../php/';
require $php_scripts . 'PDO_Connection_Select.php';
if (!$pdo = PDOConnect("foxclone_data")) {
echo( 'Connection Failed');
}
$meg = 1048576 ; // needed to convert filesize bytes to Mb
$stmt = $pdo->prepare("UPDATE `files` SET `filename` = ?, `md5` = ?, `filesize` = ?,`logtime` = now() WHERE `id` = ?") ;
$path = 'download/';
$id = NULL;
$filename = '';
foreach(glob($path.'*.*') as $file) {
$id = NULL;
$filename = basename($file) ;
$file = new SplFileInfo($file);
$extension = $file->getExtension();
$test = substr($filename, 0,12);
if ($test == 'foxclone_std') {
$id = 1;
}
if (substr($filename, 0,9) == "foxcloneV"){
$id = 2;
}
if ($extension == "deb") {
$id = 3;
}
if ($extension == "gz") {
$id = 4 ;
}
if (substr($filename, 0,4) == "news") {
$id = 5 ;
}
if (substr($filename, 0,13) == "foxclone_edge") {
$id =6;
}
$bytes = number_format(filesize($file) / 1048576, 2) ;
$getdata = (array($filename, md5_file($file),$bytes , $id)) ;
$count = $stmt->execute ($getdata) ;
IF ($count == 0) {
echo("Failed to update ".$file);
die();
}
}
?>
<--Here's where I want the pause -->
<div class="row" style="text-align:center;" </div>
<h1>Database Update Successful</h1>