新手求教:php页面中链接点击后网址后面会增加参数怎么弄的

新手求教:php页面中链接点击后网址后面会增加参数怎么弄的,第1张

a链接上加 特殊字符 "#"才会自动加载到当前a连接上;

看到这个问题,使用 js:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

<樱尺a href="御帆javascript:" flag="包邮">包邮</a>镇颂雹

<script type="text/javascript" src="http://static.takungpao.com/js/jquery.1.9.min.js"></script>

<script type="text/javascript">

$(function(){

var win_href=window.location.href,go_href,temp_zf

$("a").each(function(){

$(this).bind("click",function(){

var temp_text=$(this).attr("flag")

win_href.indexOf("?")>0?temp_zf="&":temp_zf="?"

go_href=win_href+temp_zf+temp_text

window.location.href=go_hrefreturn

})

})

})

</script>

</body>

</html>

<a href='a.php?id=2'>点击</a>

这样就把 id 传递悄坦纯给 a.php 了信毁

a.php 接收参数启咐

<?php

$id = $_GET['id']

?>

<?php

if($_GET["mobile"]==1){

    setcookie("mobile",1)

}

//要制作跳转页的时候

if($_COOKIE["mobile"]==1){

    $param="?mobile=1"

}else{

    $param="?mobile=0"

}

header("Location:/"+$param)

echo '<a href=/'.$param.'>redirect</a>'

?>

你干脆存在Cookie里面好了渣猛举知型

setcookie

不然就如碧session

这两个办法可以完美解决


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11974494.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存