大家先看下我的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>
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>
解决方案 »
- 大家帮我看看这行代码是什么意思?
- 有人对CURL 的 CURLOPT_POSTFIELDS 比较熟悉吗?帮我解释解释
- 根据ip判断地址!!!
- PHP zendstudio说连不上数据库
- mysql问题
- 鄙人想换份工作,哪位仁兄有好的信息--人在上海,顺便散分;
- 各位老大这个问题应该怎么解决啊?Fatal error: Call to undefined function mysql_connect() in F:\phptest\chap01\test-mysql.php on l
- 请大侠推荐一本PHP学习的书籍
- 如何将文本文件按照原本文件格式显示出来??
- 再问个小问题,别笑我! 继续给分!
- session_start() utf-8 问题
- 请问为什么我在插入数据库中信息后用PHP查询显示没有结果
这里的action没有吗