PHP页面跳转,菜鸟求救。。。

niesen111 2011-04-21 10:04:47
<DIV id=fm>
<form name="free" method="get" action='news.php' >
<input type="text" name=edit class="STYLE2" id=kw maxlength=150>
<SPAN class=btn_wr>
<INPUT type="submit" class=btn id=su
value="检 索" >
</SPAN>
</FORM>
</DIV>
首先判断输入框edit的内容是否为空,若非空跳转到news.php页面,且把值传给news.php中的edit2。
该怎么写。本人是PHP初学,请大哥大姐指点。。。
...全文
209 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
uptodate_huang 2011-04-22
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 binglingxiaolingling 的回复:]

JScript code
javascript 向php传递敏感字符串
javascript : encodeURIComponent( html )
php::$html [直接获得,和urlencode得到的数据一样]
php向javascript传递敏感字符串
php:htmlspecialchars( $html )
javascript: decodeURIComponent( ht……
[/Quote]
通过这种方式是不是可以实现JS 和PHP之间参数共享
zhaopei010203 2011-04-21
  • 打赏
  • 举报
回复
woyeshi
niesen111 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 yuexiangyun 的回复:]
var str = document.free.edit.value;
if(str){
document.action = "news.php?v="+str;
}

在news.php页面,$_GET['v']就是从上一个页面传过来的值。
[/Quote]这样得到的汉字出现乱码,该怎样解决?谢谢。。。
niesen111 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 t5500 的回复:]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Conten……
[/Quote]action='news.php' 是无条件跳转吧?
niesen111 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用楼主 niesen111 的回复:]
<DIV id=fm>
<form name="free" method="get" action='news.php' >
<input type="text" name=edit class="STYLE2" id=kw maxlength=150>
<SPAN class=btn_wr>
<INPUT type="submit" class=btn id=su
……
[/Quote]action='news.php' 是无条件跳转吧?
yuexiangyun 2011-04-21
  • 打赏
  • 举报
回复
var str = document.free.edit.value;
if(str){
document.action = "news.php?v="+str;
}

在news.php页面,$_GET['v']就是从上一个页面传过来的值。
乌镇程序员 2011-04-21
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function checkSubmit() {
var kw = document.getElementById('kw').value;
if (kw.length < 1) {
alert('请输入!');
return false;
}
return true;
}
</script>
</head>

<body>
<div id="fm">
<form name="free" method="get" action='news.php' onsubmit="return checkSubmit();">
<input type="text" name=edit class="STYLE2" id="kw" maxlength="150">
<span class="btn_wr">
<input type="submit" class="btn" id="su" value="检 索" >
</span>
</form>
</div>
</body>
</html>
乌镇程序员 2011-04-21
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function checkSubmit() {
var kw = document.getElementById('kw').value;
if (kw.length < 1) {
alert('请输入!');
return false;
}
return true;
}
</script>
</head>

<body>
<div id="fm">
<form name="free" method="get" action='news.php' onsubmit="return checkSubmit();">
<input type="text" name=edit class="STYLE2" id="kw" maxlength="150">
<span class="btn_wr">
<input type="submit" class="btn" id="su" value="检 索" >
</span>
</form>
</div>
</body>
</html>
niesen111 2011-04-21
  • 打赏
  • 举报
回复
谢谢...
  • 打赏
  • 举报
回复
javascript 向php传递敏感字符串
javascript : encodeURIComponent( html )
php::$html [直接获得,和urlencode得到的数据一样]
php向javascript传递敏感字符串
php:htmlspecialchars( $html )
javascript: decodeURIComponent( html )

  • 打赏
  • 举报
回复
var str = document.free.edit.value;
if(str){
document.action = "news.php?v="+escape(str);
}


因此,对于中文字符串来说,假如不希望把字符串编码格式转化成UTF-8格式的(比如原页面和目标页面的charset是一致的时候),只需要使用escape。假如你的页面是GB2312或者其他的编码,而接受参数的页面是UTF-8编码的,就要采用encodeURI或者encodeURIComponent。

在php页面用获取值urldecode($_GET['v']);

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧