繁体   English   中英

通过GET用新行传递文本字符串破坏了我的重定向

[英]Passing text string with new lines through GET is breaking my redirect

我正在提交使用javascript通过GET传递值的表单-当此表单到达提交页面时,它将运行该函数,然后在通过标题重定向时运行空白页面。 标头通过以下方式再次通过重定向传递GET:

header("location: page.php?name=" . $name . "&number=" . $number);

传递的值在文本中使用新行-

function selectvalue()
    {
        var frm = document.forms[0];
        var select = frm.browsers.value;
        if (select === "A")
            frm.message.value = "lineone\nlinetwo\nlinethree";
        else if (select === "B")
            frm.message.value = "lineone\nlinetwo\nlinethree";
        else
            frm.message.value = "lineone\nlinetwo\nlinethree";
    }

提交单行效果很好,只有多行消息。 任何援助将不胜感激。

您应该使用encodeURI将其转换为有效的URL

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM