PHP无法向mysql表中插入数据,在网页上输入时都有之前的输入记录,但数据库中的表就是没有新纪录插入
functionrec(theForm){varb=form.password.value;varc=form.password2.value;{if(c==b){if(...
function rec(theForm)
{
var b=form.password.value;
var c=form.password2.value;
{
if(c==b)
{
if(confirm("恭喜您 注册成功"))
{
location.href="file:///F:/HTML/Templates/fuzeren.html";
}
}
else
alert("对不起 密码与确认码不一致!");
}
}
function re(form)
{
form.user.value="";
form.password.value="";
form.password2.value="";
form.xm.value="";
form.select.value="";
form.select2.value="";
form.lianxi.value="";
form.dianyou.value="";
}
</script>
</HEAD>
<body bgcolor="#B0C4DE">
<form action="zhuce.php" method="post" onClick="return rec(this)">
<tr>
<td height="28"> </td>
<td colspan="2"><div align="right">密码:</div></td>
<td colspan="2"><input name="Cust_pass" type="password" id="password" maxlength="16"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><div align="right">确认密码:</div></td>
<td colspan="2"><input name="password2" type="password" id="password2"></td>
</tr>
<tr>
<td height="38" style="height:22px"> </td>
<td colspan="2"><div align="right">客户全称:</div></td>
<td colspan="2"><input name="Cust_Name" type="text" id="password22"></td>
</tr>
<tr>
<tr>
<td> </td>
<td colspan="2"><div align="right">E-mail:</div></td>
<td colspan="2"><input name="Cust_Email" type="text" id="dianyou"></td>
</tr>
<tr>
<td height="35"> </td>
<td colspan="2"><div align="right">联系电话:</div></td>
<td colspan="2"><input name="Cust_tel" type="text" id="lianxi"></td>
</tr>
<tr>
<td height="38"> </td>
<td width="27" style="width:31px"> </td>
<td width="81"><input type="submit" name="confirm" value="确认"></td>
<td><input type="reset" name="reset" value="重置" onclick="re(form)"></td>
</tr>
</table>
</form>
下面这一段为获取表单数据并插入到数据库中
$Cust_Id=$_POST[Cust_Id];
$Cust_Name=$_POST[Cust_Name];
$Cust_pass=$_POST[Cust_pass];
$Cust_Email=$_POST[Cust_Email];
$Cust_tel=$_POST[Cust_tel];
$db_host="localhost";
$db_user="root";
$db_pass="";
$db_name="tzc";
$table_name="customer";
$link=mysql_connect($db_host,$db_user,$db_pass)or die("不能连接到服务器".mysql_error());
mysql_select_db($db_name,$link);
$sql="insert into $table_name (Cust_Id,Cust_Name,Cust_pass,Cust_Email,Cust_tel) values('$Cust_Id','$Cust_Name','$Cust_pass','$Cust_Email','$Cust_tel')";
mysql_query($sql,$link);
echo '<br/>' , mysql_errno() ,': ' , mysql_error() ;
?>
<?
}
?> 展开
{
var b=form.password.value;
var c=form.password2.value;
{
if(c==b)
{
if(confirm("恭喜您 注册成功"))
{
location.href="file:///F:/HTML/Templates/fuzeren.html";
}
}
else
alert("对不起 密码与确认码不一致!");
}
}
function re(form)
{
form.user.value="";
form.password.value="";
form.password2.value="";
form.xm.value="";
form.select.value="";
form.select2.value="";
form.lianxi.value="";
form.dianyou.value="";
}
</script>
</HEAD>
<body bgcolor="#B0C4DE">
<form action="zhuce.php" method="post" onClick="return rec(this)">
<tr>
<td height="28"> </td>
<td colspan="2"><div align="right">密码:</div></td>
<td colspan="2"><input name="Cust_pass" type="password" id="password" maxlength="16"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><div align="right">确认密码:</div></td>
<td colspan="2"><input name="password2" type="password" id="password2"></td>
</tr>
<tr>
<td height="38" style="height:22px"> </td>
<td colspan="2"><div align="right">客户全称:</div></td>
<td colspan="2"><input name="Cust_Name" type="text" id="password22"></td>
</tr>
<tr>
<tr>
<td> </td>
<td colspan="2"><div align="right">E-mail:</div></td>
<td colspan="2"><input name="Cust_Email" type="text" id="dianyou"></td>
</tr>
<tr>
<td height="35"> </td>
<td colspan="2"><div align="right">联系电话:</div></td>
<td colspan="2"><input name="Cust_tel" type="text" id="lianxi"></td>
</tr>
<tr>
<td height="38"> </td>
<td width="27" style="width:31px"> </td>
<td width="81"><input type="submit" name="confirm" value="确认"></td>
<td><input type="reset" name="reset" value="重置" onclick="re(form)"></td>
</tr>
</table>
</form>
下面这一段为获取表单数据并插入到数据库中
$Cust_Id=$_POST[Cust_Id];
$Cust_Name=$_POST[Cust_Name];
$Cust_pass=$_POST[Cust_pass];
$Cust_Email=$_POST[Cust_Email];
$Cust_tel=$_POST[Cust_tel];
$db_host="localhost";
$db_user="root";
$db_pass="";
$db_name="tzc";
$table_name="customer";
$link=mysql_connect($db_host,$db_user,$db_pass)or die("不能连接到服务器".mysql_error());
mysql_select_db($db_name,$link);
$sql="insert into $table_name (Cust_Id,Cust_Name,Cust_pass,Cust_Email,Cust_tel) values('$Cust_Id','$Cust_Name','$Cust_pass','$Cust_Email','$Cust_tel')";
mysql_query($sql,$link);
echo '<br/>' , mysql_errno() ,': ' , mysql_error() ;
?>
<?
}
?> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询