代码不显示提交,这对于提交给MySQL服务器的MySQL语句很重要。我试图在表单之间插入按钮而不是最后。但奇怪的是,它并没有按照我打算展示的方式工作。
<html>
<head>
<meta charset="UTF-8">
<title></title>
<center><b> Volunteer Management </b></center>
<center>
<a href="index.php">Add User </a>
<a href="add_skill.php"> Add Skills </a>
<a href="assign_user.php">Assign User</a>
</center>
</head>
<body>
<?php
$config = parse_ini_file('/config.ini');
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['database']);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT skillName FROM skills";
$result = $conn->query($sql);
$num=mysqli_num_rows($result);
$conn->close();
?>
<form method="get">
Username: <br>
<input type="text" name="username"> <br>
Password: <br>
<input type="text" name="password"> <br>
Name: <br>
<input type="text" name="fullname"> <br>
Title: <br>
<input type="text" name="title"> <br> <br>
Permission:
<select name="permission">
<option selected disabled>Choose here</option>
<option value="0">Admin</option>
<option value="1">Project Manager</option>
<option value="2">Volunteer</option>
<option value="6">Accounting Officer</option>
</select> <br><br>
Skills: <br>
<?php
$i=0;while ($row = mysqli_fetch_assoc($result)) {
$skillName=$row['skillName'];
?>
<input type="checkbox" name="skills" value="<?php echo $skillName; ?>" ><?php echo $skillName; ?><br>
<?php $i++;} ?>
<br>
<input type="submit" name="submit>
</form>
<?php
if(isset($_GET['submit']))
{
$config = parse_ini_file('/config.ini');
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['database']);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username = $_GET['username'];
$password = $_GET['password'];
$fullname = $_GET['fullname'];
$title = $_GET['title'];
$profil = $_GET['permisssion'];
$created = date('Y-m-d H:i:s');
$sql = "INSERT INTO members (organization,login,password,name,title,profil,created) VALUES ('1','$username','$password','$fullname','$title','$permission','$created')";
$result = $conn->query($sql);
$conn->close();
}
?>
</body>
答案 0 :(得分:1)
更改
<input type="submit" name="submit>
到
<input type="submit" name="submit" value="Submit" />
答案 1 :(得分:1)
您需要重新检查您的代码。
由于submit
代码
input
之后没有结束“(双引号)
<input type="submit" name="submit">
添加结束
</form>
代码和</html>
代码