Home > Backend Development > PHP Tutorial > 求大神,smarty错误

求大神,smarty错误

WBOY
Release: 2016-06-20 12:58:06
Original
1067 people have browsed it

<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="发布留言"/>
Copy after login


我想对表单验证,原来没有问题,但在htm加入这段javascript出现smarty错误,和smarty有什么关系啊?


回复讨论(解决方案)

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");
Copy after login



在php文件里能获取htm表单的各个属性值吗?

请使用literal标签,包含js块
http://smarty.jz123.cn/language.function.literal.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template