我在我的數據庫中有一個名爲議程表的表,它與另一個稱爲會議的錶鏈接。我想通過表單編輯議程表,但我希望議程字段中的當前信息顯示在Web表單上。無法從數據庫中獲取數據以顯示在通過表單更新的字段中
<?php
include 'library/connect.php';
$agenda_id = $_GET['agenda_id'];
$result = mysql_query("SELECT agenda.*, meetings.meeting_id FROM agenda INNER JOIN meetings ON agenda.meetings = meetings.meeting_id WHERE agenda_id = '$agenda_id'");
$row = mysql_fetch_array($result);
$meeting_id = $row['meeting_id'];
?>
<form id="form1" name="form1" method="post" action="secretary_agendaSuccesful.php?agenda_id=<?php echo $agenda_id; ?>">
<table width="666" border="1">
<tr>
<td width="91">Subject:</td>
<td width="559"><span id="sprytextarea1">
<label for="subject"></label>
<textarea name="subject" id="subject" cols="45" rows="5" value="<? echo $row['subject'] ?>"></textarea>
<span class="textareaRequiredMsg">A subject is required.</span></span></td>
</tr>
<tr>
<td>Duration:</td>
<td><span id="sprytextfield1">
<label for="duration"></label>
<input type="text" name="duration" id="duration" value="<? echo $row['duration'] ?>"/>
<span class="textfieldRequiredMsg">duration in hours</span><span class="textfieldInvalidFormatMsg">Enter duration in hours</span></span></td>
</tr>
<td> </td>
<td><input type="submit" name="submitbtn" id="submitbtn" value="Submit" /></td>
</tr>
</table>
</form>
這是從數據庫中獲取信息到域中的正確方法嗎?
您的代碼對SQL注入攻擊非常開放。您不應該直接將'$ _GET'變量(或*任何*變量)插入到查詢中。請看看這個問題如何解決它,http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php – 2012-01-06 22:49:14