我有用於在表格中發送它的文本框,文本區域和PHP代碼。當我試圖提交表單時,它變得空白,甚至其他部分也不起作用。我無法插入文本區域值
代碼 -
<form action="" method="post" class="niceform">
<fieldset>
<dl><dd> </dd></dl>
<dl>
<dt>
<label for="service">Service Name:</label>
</dt>
<dd><input type="text" name="service_name" id="" size="39" /></dd>
</dl>
<dl>
<dt><label for="comments">Comments:</label></dt>
<dd>
<textarea name="comments" id="comments" rows="5" cols="36"></textarea>
</dd>
</dl>
<dl class="submit">
<input type="submit" name="submit" id="submit" value="Submit" />
<br />
<br />
</dl>
<?php
$service_name = $_POST['service_name'];
$comment = $_POST['comments'];
mysql_connect("localhost","root","");
mysql_select_db("easylaw");
$query = "INSERT INTO service_cat VALUES('','$service_name','$comment')";
mysql_query($query);
$result = mysql_affected_rows();
if($result==1)
{
?>
<div class="valid_box">Your Record Submitted. </div>
<?php
}
else
{
?>
<div class="warning_box">Something is Wrong.</div>
}
<?php
?>
</fieldset>
</form>
任何機構可以告訴我什麼都可以,這樣它不會,並沒有什麼太出了問題..
謝謝:)
什麼是在$ _ POST的內容?後續代碼var_dump($ _ POST); – 2012-03-20 12:27:10
http://bobby-tables.com/ – Quentin 2012-03-20 12:28:20
您的腳本容易受到通過SQL注入篡改數據庫的攻擊。請在'$ service_name = mysql_real_escape_string($ _ POST ['service_name']);' – 2012-03-20 12:29:18