F:为何总出现“http标题已经写入到客户浏览器,任何http标题的修改必须在写入页内容之前”?
Q:在这页的最前面加
<%Response.Buffer=True%>
因为以前的默认buffer=true,而你的IIS默认为false,所以要加
在使用cookies时,写cookies时必须是在没有向浏览器写数据之前,你的
response.Cookies("bookshop")("username")=trim(request("username"))
response.Cookies("bookshop").expires=date+1
这两句之前有东西写到浏览器了,所以产生上面的错误,解决办法是
在页面开始加
<% response.buffer=true %>
=====================================================================================
禁止页面缓存:
ASP
<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader “Pragma“,“no-cache“
Response.AddHeader “cache-control“,“private“
Response.CacheControl = “no-cache“
%>
PHP
<?php
header(“Cache-Control: no-cache, must-revalidate“);
header(“Pragma: no-cache“);
?>
=====================================================================================
防止站外提交:
<%dim ComeUrl,cUrl
ComeUrl=lcase(trim(request.ServerVariables("HTTP_REFERER")))
if ComeUrl="" then
response.write "<br><p align=center><font color='red'>对不起,为了系统安全,不允许直接输入地址访问本系统的后台管理页面。</font></p>"
response.end
else
cUrl=trim("http://" & Request.ServerVariables("SERVER_NAME"))
if mid(ComeUrl,len(cUrl)+1,1)=":" then
cUrl=cUrl & ":" & Request.ServerVariables("SERVER_PORT")
end if
cUrl=lcase(cUrl & request.ServerVariables("SCRIPT_NAME"))
if lcase(left(ComeUrl,instrrev(ComeUrl,"/")))<>lcase(left(cUrl,instrrev(cUrl,"/"))) then
response.write "<br><p align=center><font color='red'>对不起,为了系统安全,不允许从外部链接地址访问本系统的后台管理页面。</font></p>"
response.end
end if
end if
%>
=====================================================================================
用图片替换提交按钮和重置按钮
提交 <a href="#" onclick="document.form.submit();"><img src="".........></a>
重置 <a href="#" onclick="document.form.reset();"><img src="".........></a>
=====================================================================================
搜索日期格式
sql = "select *,DailyReport.id as Tid from DailyReport,T_Login where DailyReport.pid = T_login.id and T_Login.CompanyName like '%"&CompanyName&"%' and convert(varchar(11),DailyReport.ReportDate,121) like '%"&ReportDate&"%' and convert(varchar(11),DailyReport.InputDate,121) like '%"&InputDate&"%' and DailyReport.AuditFlag = 0"
convert(varchar(11),DailyReport.ReportDate,121) like '%"&2004-12-18&"%'
博客主要围绕ASP和PHP开发中的常见问题展开。如ASP中出现http标题修改错误的解决办法是在页面开始加response.buffer=true;介绍了ASP和PHP禁止页面缓存的代码;还提及防止站外提交的方法、用图片替换按钮以及搜索日期格式的SQL语句。
1万+

被折叠的 条评论
为什么被折叠?



