dougai3418 2012-12-18 21:16
浏览 31
已采纳

带有传递值的重定向页面

I have a real problem and it's syntax problem. Normally when I need redirect any page I just use header function. Sometimes I use a variable when I need like below:

if(condition) header("Location: home.php?wrong=1");

Sometimes it could be:

if(condition) header("Location: home.php?wrong=1&&success=2");

There is no problem with direct use of variable(wrong or success). And when I need redirect a value from html form via post method, I use this code and it works:

if (condition) header("Location: home.php?id=".$_POST['topic_id']);

But I need more, I need pass another value too. So I use:

if (condition) header("Location: home.php?id=".$_POST['topic_id']&&wrong=1);

And this time I become a dumb. Can anyone help me out by providing proper syntax? I just need pass the WRONG=1 part too.

  • 写回答

3条回答 默认 最新

  • duaijiao0648 2012-12-18 21:17
    关注

    you need:

    if (condition) header("Location: home.php?id=" . $_POST['topic_id'] . "&wrong=1");
    

    or

    if (condition) header("Location: home.php?id={$_POST['topic_id']}&wrong=1");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作