运行此代码时,它显示问题“语法错误,文件意外结束”。我想做的是,我想将数据插入数据库中。但不幸的是,出现了问题。谁能帮助我解决这个问题?我需要完成任务,这是我第二次使用PHP和HTML进行项目。
这是我学习的作业
<?php
include_once("session.php");
include('dateFunctions.php');
include("navbar.php");
if(isset($_POST['TRAINING_NAME'])){
$hostname = "localhost";
$username = "root";
$password = "";
$databaseName = "training";
// connect to mysql database
$connect = mysqli_connect($hostname, $username, $password,
$databaseName);
// mysql select query
$query = "SELECT TRAINING_NAME FROM `training`";
// to fetch data from database
$result2 = mysqli_query($connect, $query);
$options = "";
while($row2 = mysqli_fetch_array($result2))
{
$options = $options."<option>$row2[0]</option>";
}
?>
<html>
//this code is for alert warning popup
<script>
function AlertBox() {
alert("Added Succesfully");
}
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<head>
<title>Register Training</title>
</head>
// this is a design for the box
<style>
table ,th ,td{
border: 0px solid black !important;
border-collapse:collapse !important; }
</style>
<?php
if(isset($_POST["TRAINING_NAME"])){
$UID = $_SESSION['USERID'];
$UTID = $_SESSION['TRAINING_ID'];
//to insert all the data in the form into training_status
mysql_query("INSERT INTO TRAINING_STATUS VALUES (NULL,'<?php echo $dt->format('Y-m-d h:i:s.a');?>', $UID, $UTID );");
echo " Added Successfully ";
}
?>
<body>
<br>
// the form created
<center>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<h1 align="center"><font face="Georgia" color="#141042" size="45" >TRAINING REGISTRATION</font></h1>
<fieldset style="background-color: #424242">
<legend style="color: white">TRAINING DETAILS </legend>
<table style="color: white">
<!-- Method to make dropdown list -->
<tr>
<td>TRAINING NAME : </td>
<td>
<select>
<?php echo $options;?>
</select>
</td>
</tr>
<tr>
<td> ATTENDANCE DATE & TIME: </td>
<td><?php
$dt = new DateTime();
echo $dt->format('Y-m-d h:i:s.a'); // format of the date and time
?>
</td>
</tr>
</table>
</fieldset>
<div style="width:100%;position:absolute;vertical-align:middle;text-align:center;">
<center><legend><button type="submit">ATTEND TRAINING</button>
</legend>
</center>
</div>
</form>
</center>
</body>
</html>