如果我在PHP文件中製作insert_teacher('bla bla','bla bla','dqsd')
,但是當我想用HTML表單製作它時,它不會顯示任何內容,並且我的數據庫中沒有插入任何內容。HTML表單不適用於PHP代碼
<?php
include_once("resources/functions.php");
echo 1;
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$exp=$_POST['exp'];
$sub=$_POST['sub'];
$insert=insert_teacher($name,$exp,'dqsd');// return 1 or 0
echo $insert;
}
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header>
<h1>City Gallery</h1>
</header>
<ul class="sidenav">
<li><a href="index.php">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a class="active" href="setup_teachers.php">Teachers Section</a></li>
</ul>
<div class="content">
<h3 class="warning"><?php if(isset($b)) echo $b; ?></h3>
<h3>Adding teachers information</h3>
<div>
<form action="" method="POST" >
<label for="fname">FullName</label>
<input type="text" id="fname" name="name">
<label for="lname">Experience</label>
<input type="text" id="lname" name="exp">
<label for="subject">Subject</label>
<select id="country" name="sub">
<option value="physics">physique</option>
<option value="maths">mathematique</option>
<option value="english">Anglais</option>
</select>
<input type="submit">
</form>
</div>
</div>
</body>
</html>
我們可能不知道什麼'insert_teacher()'是。順便說一句,學習AJAX。 – PHPglue
爲什麼你複製並粘貼相同的文字3次? – chris85
可能重複[何時使用單引號,雙引號和反引號?](http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks) –