Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have the code and I just need to add a php of time and date on the view entry

ID: 3850196 • Letter: I

Question

I have the code and I just need to add a php of time and date on the view entry page.

<html> <head> <title> output page </title></head> <body>
<?php
$email = $_REQUEST["email"];
$name = $_REQUEST["name"];
$comment = $_REQUEST["comment"];
$subject = $_REQUEST["subject"];
$email = trim($email);
$name = trim($name);
$comment = trim($comment);
$subject = trim($subject);
$flag=0;

if($email == ""){
$flag =1;
echo "Email is a required field.";
}

if($name == ""){
$flag =1;
echo "Name is a required field.";
}

if($comment == ""){
$flag =1;
echo "Comment is a required field.";
}

if($subject == ""){
$flag =1;
echo "Subject is a required field.";
}


if($flag==0) {
       $data = "$name, $email, $comment, $subject ";
$file = "comment.txt";
$fp = fopen($file, "a");
fwrite($fp, $data);
fclose($fp);
echo "Thank you for submitting the form!";
echo $flag;
}
?>

</body>
</html>

Explanation / Answer

<html> <head>
<title> output page </title></head>
<body>

<?php
$email = $_REQUEST["email"];
$name = $_REQUEST["name"];
$comment = $_REQUEST["comment"];
$subject = $_REQUEST["subject"];
$email = trim($email);
$name = trim($name);
$comment = trim($comment);
$subject = trim($subject);
$flag=0;
if($email == ""){
$flag =1;
echo "Email is a required field.";
}
if($name == ""){
$flag =1;
echo "Name is a required field.";
}
if($comment == ""){
$flag =1;
echo "Comment is a required field.";
}
if($subject == ""){
$flag =1;
echo "Subject is a required field.";
}

if($flag==0) {
$data = "$name, $email, $comment, $subject ";
$file = "comment.txt";
$fp = fopen($file, "a");
fwrite($fp, $data);
fclose($fp);
echo "Thank you for submitting the form!";
echo $flag;
}
?>
<div>
<span><?php echo date(DATE_RFC2822);?><span>
</div>
</body>
</html>