对不起,基本问题。我在 Stackoverflow 上查看了其他答案,但这里是:
我有一个简单的表格,应该将数据发布到我的 mysql 数据库中:
<form id="theatre" method="post" action="{$HTTP_HOST}admin/addTheatre.php" autocomplete="on">
<input type="hidden" name="id">
<fieldset>
<label>Please fill in the relevent fields.</label>
<section>
<label for="year">Year</label>
<div>
<select name="year" id="year">
<optgroup label="Year">
<option>2013</option>
<option>2012</option>
<option>2011</option>
<option>2010</option>
<option>2009</option>
<option>2008</option>
<option>2007</option>
<option>2006</option>
</optgroup>
</select>
</div>
</section>
<section><label for="part">Part</label>
<div>
<input type="text" id="part" name="part" title="A Tooltip">
</div>
</section>
<section><label for="name">Name</label>
<div>
<input type="text" id="name" name="name" title="A Tooltip">
</div>
</section>
<section><label for="theatre">Theatre</label>
<div>
<input type="text" id="theatre" name="theatre" title="A Tooltip">
</div>
</section>
<section><label for="director">Director</label>
<div>
<input type="text" id="director" name="director" title="A Tooltip">
</div>
</section>
<section>
<div>
<button name="submit" class="submit" type="submit">Submit</button>
</div>
</section>
</fieldset>
</form>
在 addTheatre.php 文件中我有:
if(isset($_POST['submit'])){
hcDB::getInstance()->insert_theatre($_POST['year'], $_POST['part'], $_POST['name'], $_POST['theatre'], $_POST['director']);
}
我应该运行以下功能:
function insert_theatre($year, $part, $name, $theatre, $director) {
$year = $this->real_escape_string($year);
$part = $this->real_escape_string($part);
$name = $this->real_escape_string($name);
$theatre = $this->real_escape_string($theatre);
$director = $this->real_escape_string($director);
$this->query("INSERT INTO theatre (`year`, `part`, `name`, `theatre`, `director`)" .
" VALUES (" . $year . "' , '" . $part . "' , '" . $name . "' , '" . $theatre . "' , '" . $director . "')");
}
据我所知,没有提交任何内容。你可能会说,我是新手,所以为无能道歉!
提前感谢您的帮助。