Getting a unified $_GET array regardless of how you submit information

纵饮孤独 提交于 2019-12-13 04:16:24

问题


So I am submitting this link into my php code:

For some reason I cannot even use example.com in the url below, but just add the directory to the script before.

https://www.example.com/test.php?info1234=3177%3B315961%3B317451%3B315511&info3598=121618%3B136803%3B13830%3B20532

The above example.com url is 1 SINGULAR string. The user is ONLY submitted ONE thing. That one thing happens to be a php url which contains its own parameters.

However, when I submit it using the the form, I get this $_GET array (This is my desired outcome but the other way is fine too):

Array
(
    [myurl] => https://www.example.com/test.php?info1234=3177;315961;317451;315511
    [info3598] => 121618;136803;13830;20532
)

And then if I submit it by putting the myurl into the actual url myself into my program's url myself. If I typed this url, and submitted it localhost/test.php?myurl=https://www.example.com/test.php?info1234=3177%3B315961%3B317451%3B315511&info3598=121618%3B136803%3B13830%3B20532, I get this $_GET array:

Array
(
    [myurl] => https://www.example.com/test.php?info1234=3177%3B315961%3B317451%3B315511&info3598=121618%3B136803%3B13830%3B20532
)

test.php

<?php
print_r($_GET);

?>

<form action="test.php" method="get">
  myurl: <input type="text" name="myurl"><br>
  <input type="submit" value="Submit">
</form>

回答1:


Form submission - submits form data. You'll have to Add the extra parameter as a hidden input. ie:

<input type="hidden" id="info" name="info3595" value="entervaluehereinsuitalbleformat">



回答2:


try this:-

<form action="test.php" method="GET">

myurl: <input type="text" name="myurl"><br>

<input type="hidden" id="info" name="info1234" value="enter_value">
<input type="submit" value="submit">

</form>

i hope it's useful



来源:https://stackoverflow.com/questions/54438589/getting-a-unified-get-array-regardless-of-how-you-submit-information

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!