Php post method not getting data from url

喜欢而已 提交于 2021-02-17 06:35:07

问题


I have an URL which is to be used for getting post data after pasting and pressing enter in the browser. My link is : http://vtrails.us/mixtape-builder/?song_urls=http://vtrails.us/wp-content/uploads/2015/12/mpthreetest.mp3&song_artist=ganja

<?php                       
    if(isset($_POST['song_urls']) && !empty($_POST['song_urls'])){
        $song_url = $_POST['song_urls'];
        $song_artist = $_POST['song_artist'];
    }
    echo $song_url;
    echo $song_artist;
?>

But i am not getting any of them.So what can i do now?


回答1:


If you use $_GET instead of $_POST you will get desired result:

Here is the code

<?php                       
   if(isset($_POST['song_urls']) && !empty($_POST['song_urls'])){
        $song_url = $_POST['song_urls'];
        $song_artist = $_POST['song_artist'];
   }
   echo $song_url;
   echo $song_artist;
?>



回答2:


Its $_GET, not $_POST. Do this:

<?php                       
    if(isset($_GET['song_urls']) && !empty($_GET['song_urls'])){
        $song_url = $_GET['song_urls'];
        $song_artist = $_GET['song_artist'];
    }
    echo $song_url;
    echo $song_artist;
?>


来源:https://stackoverflow.com/questions/34295257/php-post-method-not-getting-data-from-url

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