dousi2013 2015-04-26 15:52
浏览 70
已采纳

元刷新标记将分号添加到URL(;)

I have a PHP/HTML form that when the submit form button is pressed it is supposed make the database changes and redirect the page to another URL to view the form details. The next page requires receiving two variables via GET in order to load the information from the database.

I am using the following line of code to redirect the page after the form is submitted:

echo '<META HTTP-EQUIV="refresh" Content="0;URL=http://grserviceswap.isys489.com/dev/Abraham/providerViewsAPost.php?SPPostingID=' . $PostingID . '&UserID=' . $UserID . '"/>';

The problem is that when it redirects it adds two semicolons like this:

http://grserviceswap.isys489.com/dev/Abraham/providerViewsAPost.php?SPPostingID=7;%20&UserID=33;

The semicolon add the end prevents the page from loading properly. I can remove it manually and it will work, but normal users won't know to do that.

How can I get the meta refresh to not add the semicolons?

  • 写回答

1条回答 默认 最新

  • douzi0609 2015-04-26 16:20
    关注

    You should be sanitizing GET variables to protect against XSS (cross site scripting) attacks. If both are integers, you can enforce that.

    echo '<META HTTP-EQUIV="refresh" Content="0;URL=http://grserviceswap.isys489.com/dev/Abraham/providerViewsAPost.php?SPPostingID=' . intval($PostingID) . '&amp;UserID=' . intval($UserID) . '"/>';
    

    Note I also changed the & to &amp; which is the correct HTML encoding.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改