0

I need to put time and date in the script, anyone please help

1. questions 

<?php
$qid = "Quiz ID-00";
?>
<html>
<head>
<title><? echo "Gamers Pub $qid"; ?></title>
</head>
<body>
<p><h3><? echo "SiteName $qid"; ?></h3></p>
<form action="/forums/results.php" method="post">
<p>Username: <input type="text" name="name"></p>
<p>1.) Question number one is?<br>
<input type="radio" name="q1" value="Answer1"> Answer1<br>
<input type="radio" name="q1" value="Answer2"> Answer2</p>
<p>2.) Question number two is?<br>
<input type="radio" name="q2" value="Answer1"> Answer1<br>
<input type="radio" name="q2" value="Answer2"> Answer2</p>
<p>3.) Question number three is?<br>
<input type="radio" name="q3" value="Answer1"> Answer1<br>
<input type="radio" name="q3" value="Answer"> Answer2</p>
<p>4.) Question number four is?<br>
<input type="radio" name="q4" value="Answer1"> Answer1<br>
<input type="radio" name="q4" value="Answer2"> Answer2</p>
<p>5.) Question number five is?<br>
<input type="radio" name="q5" value="Answer1"> Answer1<br>
<input type="radio" name="q5" value="Answer2"> Answer2</p>
<p><input type="submit" name="submit" value="Submit Quiz"></p>
<input type="hidden" name="qp" value="quiz00.php">
</form>
</body>
</html>

2. results (action script)

<?php
$title = "Quiz Results";
echo "<title>$title</title>";
// Below gets the answers from the page before //
if (isset ($_POST['submit'])) {
  $name = $_POST['name'];
  $q1 = $_POST['q1'];
  $q2 = $_POST['q2'];
  $q3 = $_POST['q3'];
  $q4 = $_POST['q4'];
  $q5 = $_POST['q5'];
  $qp = $_POST['qp'];
}
// Below checks to see if you forgot anything //
if ($name == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q1 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q2 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q3 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q4 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
if ($q5 == "") {
  die ("You forgot something, go back and check over your quiz.");
}
// Below is where the answers are actually displayed //
{
echo<<<EOT
<p>Results: $name<br>
1.) $q1<br>
2.) $q2<br>
3.) $q3<br>
4.) $q4<br>
5.) $q5</p>
<p><a href="/forums/$qp">Go Back To Quiz?</a>

EOT;
}
?>
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by boomop
0
<?php 
$now = time();
echo date("m/d/y h:i a", $now);
?>

I would definitely look up the time() function and date() function to get everything formatted the way you want it.
time "returns the current time measured in the number of seconds since the Unix Epoch" and is dependent on the servers date/time setting, usually for the timezone that the server is set up in.

date can take a 'format' to output the date/time in and a variable with the timestamp you want to output

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.