我目前正在創建一個自定義'調查'形式的表單,但由於我是新手到PHP,我不完全知道如何提交條目到數據庫(並使字段集需要)。PHP表單提交到SQL數據庫
我目前有3個字段集,讓我們稱他們是誰,什麼時候以及什麼。誰是簡單的選擇領域,所以沒有問題。然而,如果是一組無線電,但其中兩個有關聯的文本字段,如果選擇收音機,則需要填寫。什麼是textarea。
我明白這一點了:
- 形式的行動是一個PHP文件(其中包含數據庫連接和 提交)
- 形式方法後
與數據庫,我該怎麼辦提交這些數據?特別是第二個字段集。
目前的形式:
<form action="heroes.php" method="post">
<fieldset>
<h2 class="req">Which Hero?</h2>
<span class="help">We need to know what hero says what line.</span>
<label><span class="title">Hero: </span>
<select>
<?php include 'files/hero-select.php'; ?>
</select>
</label>
</fieldset>
<fieldset id="when">
<h2 class="req">When?</h2>
<span class="help">When is it said? Who is it said to?</span>
<label>To Boss: <input name="when" type="radio" value="boss" /> <input type="text" placeholder="Boss Name" id="bname" size="10" /></label>
<label>To Hero: <input name="when" type="radio" value="hero" /> <input type="text" placeholder="Hero Name" id="hname" size="10" /></label>
<label>Low Health: <input name="when" type="radio" value="lowhp" /></label>
<label>Defeat: <input name="when" type="radio" value="defeat" /></label>
<label>Boss Defeat: <input name="when" type="radio" value="bossd" /></label>
<label>Mob Defeat: <input name="when" type="radio" value="mob" /></label>
<label>Emote: <input name="when" type="radio" value="emote" /></label>
<label>Item Pickup: <input name="when" type="radio" value="item" /></label>
</fieldset>
<fieldset>
<h2 class="req">Quote</h2>
<span class="help">What was said.</span>
<textarea id="quote"></textarea>
</fieldset>
<fieldset>
<input type="submit" value="Submit" /><input type="reset" value="Clear" />
</fieldset>
</form>
英雄select.php: 黑豹
<option value="Black Widow">
Black Widow
</option>
<option value="Cable">
Cable
</option>
<option value="Captain America">
Captain America
</option>
<option value="Colossus">
Colossus
</option>
<option value="Cyclops">
Cyclops
</option>
<option value="Daredevil">
Daredevil
</option>
<option value="Deadpool">
Deadpool
</option>
<option value="Emma Frost">
Emma Frost
</option>
<option value="Gambit">
Gambit
</option>
<option value="Ghost Rider">
Ghost Rider
</option>
<option value="Hawkeye">
Hawkeye
</option>
<option value="Hulk">
Hulk
</option>
<option value="Human Torch">
Human Torch
</option>
<option value="Iron Man">
Iron Man
</option>
<option value="Jean Grey">
Jean Grey
</option>
<option value="Loki">
Loki
</option>
<option value="Luke Cage">
Luke Cage
</option>
<option value="Moon Knight">
Moon Knight
</option>
<option value="Ms Marvel">
Ms Marvel
</option>
<option value="Nightcrawler">
Nightcrawler
</option>
<option value="Punisher">
Punisher
</option>
<option value="Rocket Raccoon">
Rocket Raccoon
</option>
<option value="Scarlet Witch">
Scarlet Witch
</option>
<option value="Spider-Man">
Spider-Man
</option>
<option value="Squirrel Girl">
Squirrel Girl
</option>
<option value="Storm">
Storm
</option>
<option value="Thing">
Thing
</option>
<option value="Thor">
Thor
</option>
<option value="Wolverine">
Wolverine
</option>
您可以發佈您已有的代碼 –
@Templar編輯它。 – Spedwards
您在heroes.php中有哪些代碼? –