1

Can't get params from $_POST. I'm sure that the code is right cause they are given by a book.

<html>
<head>
  <title>Book-O-Rama Catalog Search</title>
</head>

<body>
  <h1>Book-O-Rama Catalog Search</h1>

  <form action="results.php" method="post">
    Choose Search Type:<br />
    <select name="searchtype">
      <option value="author">Author
      <option value="title">Title
      <option value="isbn">ISBN
    </select>
    <br />
    Enter Search Term:<br />
    <input name="searchterm" type="text" size="40">
    <br />
    <input type="submit" name="submit" value="Search">
  </form>

</body>
</html>

and this is the .php script to get the params.

<html>
<head>
  <title>Book-O-Rama Search Results</title>
</head>
<body>
<h1>Book-O-Rama Search Results</h1>
<?php
  // create short variable names
  $searchtype=$_POST['searchtype'];
  $searchterm=trim($_POST['searchterm']);

    echo "Search type: ".$searchtype."</br>";
    echo "search term: ".$searchterm."</br>";

  if (!$searchtype || !$searchterm) {
     echo 'You have not entered search details.  Please go back and try again.';
     exit;
  }

?>
</body>
</html>

$searchtype and $searchterm are always empty. I can'

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Jiawei Yang
  • 1,553
  • 2
  • 12
  • 17

2 Answers2

0

The option tag should be closed

<html>
<head>
  <title>Book-O-Rama Catalog Search</title>
</head>

<body>
  <h1>Book-O-Rama Catalog Search</h1>

  <form action="results.php" method="post">
    Choose Search Type:<br />
    <select name="searchtype">
      <option value="author">Author</option>
      <option value="title">Title</option>
      <option value="isbn">ISBN</option>
    </select>
    <br />
    Enter Search Term:<br />
    <input name="searchterm" type="text" size="40">
    <br />
    <input type="submit" name="submit" value="Search">
  </form>

</body>
</html>
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
0

I am using phpstorm 2017.2, and below method work for me.

  1. click dropdown list on the run button left
  2. click edit configurations...
  3. click +
  4. select php build-in web server, and config port (like 8888), and select your document root.
  5. apply and ok
  6. click dropdown list on the run button left
  7. select the web server you config in step 4
  8. click run button
  9. click dropdown list on the run button left
  10. click edit configurations...
  11. find your php file in javascript debug, then click
  12. fix url port 63342 to 8888(config in step 4)
  13. apply and ok
  14. click dropdown list on the run button left
  15. select the php file you want run
  16. click run button

end

aotian16
  • 767
  • 1
  • 10
  • 21