Home > Article > Backend Development > 求大神,smarty错误
<SCRIPT language=javascript>function CheckPost(){ if(myform.user.value=""); { alert("请填写用户"); myform.user.focus(); return false; } if(myform.title.value.lengh<5){ alert("标题不能小于5字符"); myform.title.focus(); return false; }}</SCRIPT> <div class="form"><form action="message.php" method="post" name="myform" onsubmit="return CheckPost();">用户:<input type="text" size="10" name="user"/><br>标题:<input type="text" name="title" /><br/>内容:<textarea name="content"></textarea><br/><input type ="submit" name="submit" value="发布留言"/>
js 代码被当做模板解释了吧?
js 代码被当做模板解释了吧?
include ('./global.php');if($_POST['submit']){ $sql="INSERT INTO `message`(`id`, `user`, `title`, `content`, `lastdate`) " . "VALUES ('','$_POST[user]','$_POST[title]','$_POST[content]',now())"; $query=$db->query($sql); echo "<script> {window.alert('发布成功')} </script>";}$smarty->display("message.htm");
请使用literal标签,包含js块
http://smarty.jz123.cn/language.function.literal.html