大家先看下我的php程序写的没有成为吧!
php程序命名:login.php<?php
require_once("conn_inc.php");
require_once("smarty_inc.php");
if ($_POST["submit"]) {
$name= $_POST['name'];
$pass=  $_POST['pass'];
$mail=  $_POST['mail'];
$content=$_POST['content'];
$sql="insert into  `news_list` (name,pass,`mail`,`content`) values ('$name','$pass','$mail','$content')";
$query=mysql_query($sql);
if ($query) {
echo "<script>alert('用户添加 成功,请返回!')</script>";
echo "<script>location.href='login.php'</script>";
}else {
echo "<script>alert('用户添加失败')</script>";
}
}
$smarty->display("login1.tpl.html");
?>
以下是我模板部分程序代码 为当我单击"提交"的时候就自动返回在网站的根目录了,并且写不在数据库中,当我把所有JS去掉就可以了,报告错误如下
行40
字符:3
错误:‘tnobj’为空字符或不是对象
代码:0
我在程序中没有找到‘tnobj’这个字符
大家帮助我看下什么原因!
模板文件名为:login1.tpl.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
{literal}
<SCRIPT language=JavaScript>
<!--
function checkform()
{    if (addnew.name.value=="") {
              alert("请输入用户名!");
              addnew.name.focus();              
                  return (false);
  }
    if (addnew.pass.value=="") {
              alert("请输入密码!");
              addnew.pass.focus();              
                  return (false);
  }
  if(document.addnew.pwd2.value==""){
alert("请输入您的确认密码!");
document.addnew.pwd2.focus();
return false;
}
  if (document.addnew.pwd2.value!=document.addnew.pass.value ){
alert("两次填写的密码不一致,请重新填写!"); 
document.addnew.pass.focus();
document.addnew.pass.select();
return false; 

  return true;
}
//-->
</SCRIPT>
{/literal}
<FORM name=addnew onsubmit="return checkform()" action=" " method="POST">
<table border="1" align="center" width="50%">
<tr>
<td>用户名:</td>
<td><input type="text" name="name" size="30"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pass" size="30"></td>
</tr>
<tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pwd2" size="30"></td>
</tr>
<tr>
<td>注册邮箱:</td>
<td><input name="mail" type="text" size="30"></td>
</tr>
<tr>
<td>详细介绍</td>
<td><textarea rows="10" cols="40" name="content"></textarea></td>
</tr>
<tr><td colspan="2">
 <INPUT class=form type=submit value=添加 name=Submit>
</td></tr>
</table>
</form>
</body>
</html>