简体   繁体   中英

Why is this php array not getting anything?

I'm trying to submit a 'defacto' option array (although it looks like a search bar) to a php file and show the results that I sent. This is what it looks like now:

在此输入图像描述 Link to image: http://i.imgur.com/Ak4dk.png

And so what I did was that I changed the submit.php from this:

<?php print_r($_REQUEST); ?>

To this:

<?php

if(isset($_POST['$_REQUEST']))
{
  $aVenues = $_POST['select3'];

  if(!isset($aVenues))
  {
    echo("<p>You didn't select any venues!</p>\n");
  }
  else
  {
    $nVenues = count($aVenues);

    echo("<p>You selected $nVenues venues: ");
    for($i=0; $i < $nVenues; $i++)
    {
      echo($aVenues[$i] . " ");
    }
    echo("</p>");
  }
}

?>

Here's a link to the page , and as you can see the submit.php shows an empty page, why is this :/ ? Thank youu :)

Try

if(isset($_POST['select3'])) 

Not what you have at the moment. That index won't exist in $_POST.

the if

if(isset($_POST['$_REQUEST']))

fails.

$_REQUEST and $_POST are both different arrays, 1 containing only POST data, the other combining POST and GET.

The check should be (I assume)

if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) { }

To verify that data actually has been posted to the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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