问题
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