简体   繁体   English

通过 php 在 url 中传递参数

[英]pass parameters in url via php

i am tying to pass some parameters in my URL via php.我想通过 php 在我的 URL 中传递一些参数。 Below is my code i have tried.下面是我尝试过的代码。

 <button onclick="window.location.href='process2.php?name='.$fname. '&Usrname='.$name " style="border-radius:5px;margin-right:10%;font-size:20px;box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);background-color:#d29dfa">

i guess there is some errors with the qoutes.我想 qoutes 有一些错误。 how to solve it?如何解决?

Instead of window.location.href which will return the current URL from the address bar, you can use window.location.assign() which will open a new document for a given address.您可以使用window.location.assign()而不是window.location.href ,它将从地址栏中返回当前 URL ,这将为给定的地址打开一个新文档。

Check below:检查以下:

 <?php echo '<button onclick="window.location.assign(\"process2.php?name='.$fname.'&Usrname='.$name.'\");" style="border-radius:5px;margin-right:10%;font-size:20px;box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);background-color:#d29dfa">'; ?>

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

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