代码没有显示提交,这对于将 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>
最佳答案
改变
<input type="submit" name="submit>
到
<input type="submit" name="submit" value="Submit" />
关于php - HTML - 尽管有说明,但未出现提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39989637/