在index.php加代码,不成功,请教

2016-07-07 15:05 来源:www.chinab4c.com 作者:ecshop专家

if($_REQUEST['action'] == 'act_add_message'){
$username = isset($_POST['username']) ? trim($_POST['username']) : ''; //取不到值,为何?
$tel = isset($_POST['tel']) ? trim($_POST['tel']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$ordertype = isset($_POST['ordertype']) ? trim($_POST['ordertype']) : '';
$postalcode = isset($_POST['postalcode']) ? trim($_POST['postalcode']) : '';
$addess = isset($_POST['addess']) ? trim($_POST['addess']) : '';
$gustbook = isset($_POST['gustbook']) ? trim($_POST['gustbook']) : '';
if($username == "" || $tel == ""){
echo "为空!";

}else {
$sql = "insert into ". $ecs->table('ky_order')."(username,tel,ordertype,postalcode,addess,gustbook,email) values ('$username','$tel','$ordertype','$postalcode','$addess','$gustbook','$email')";
echo $sql."<br>";
$db->query($sql);

echo "OK!!!";
}

}

回答:
<form action="index.php?action=act_add_message" method="post" id="registerForm"name="registerForm">
<table style=" margin-top:15px;" width="613" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#8F92A1" bgcolor="#E8E8E6">
<tr>

<td width="70" height="28"><div align="right">姓名:</div></td>
<td width="222"> &nbsp;
<input type="text" name="p_name" id="nameid" /></td>
<td width="77"><div align="right">电话:</div></td>
<td width="234">&nbsp;
<input type="text" name="p_telephone"id="telid"/></td>
</tr>

<tr>
<td height="28"><div align="right">订购类型:</div></td>
<td colspan="3">&nbsp;
<select name="p_type">
<option> sssssoption>
<option>wwwwww</option>
<option>bbbbb</option>

<option>便携旅行装 原价:614元 现价:582元 (内含64片)</option>
</select></td>
</tr>
<tr>
<td height="28"><div align="right">地址:</div></td>
<td>&nbsp;
<input type="text" name="p_address" /></td>
<td><div align="right">邮编:</div></td>

<td>&nbsp;
<input type="text" name="p_zip" /></td>
</tr>
<tr>
<td height="28"><div align="right">E-mail:</div></td>
<td>&nbsp;
<input type="text" name="p_email" /></td>
<td>&nbsp;</td>

<td>&nbsp;</td>
</tr>
<tr>
<td height="91"><div align="right">留言:</div></td>
<td colspan="3">&nbsp;
<textarea name="p_details" cols="60" rows="5"></textarea></td></tr>
<tr>
<td height="33" colspan="4">

<inputtype="submit" onclick="return checkSignupForm();" name="Submit" value="提交" />
<input class="bt" style="cursor:hand;" type="reset" name="Submit2" value="重填" /></td>
</tr>
</table>
</form>
静态页面

你也以在themes/default/index.dwt中修改适一下!

在那个位置,加了什么代码?