簡體   English   中英

PHP如果isset變量未顯示

[英]PHP if isset variable not showing

我正在嘗試從表單中獲取變量,但是它什么也沒有給我,我也做了var_dump的工作,它告訴我數組為0,所以表單不發送數據。 我嘗試了很多事情,但我認為我有某種錯誤,或者我的安裝不好。 我當前使用的軟件是Windows 10上的WampServer,PHP 7.0.10版和PHPStorm。

<html>
<head lang="en">
<meta charset="UTF-8">
</head>
   <body>

<!-- language: PHP -->   
<?php
if(isset($_POST['age'])) {
    $varKapitaal = $_POST['age'];
    echo $varKapitaal;
}
?>

    <h1>Fill in the form</h1>

    <form method="POST" action="">
        <p>age:</p>
        <input type="text" name="age">
        <input type="submit" name="submit">
    </form>
</body>
</html>

不,這不是錯誤。 您只需要指定操作url,該帖子必須在其中查看數據。

我使用Xampp,並創建目錄和文件C:\\ xampp \\ htdocs \\ try \\ index.php

<html>
   <head lang="en">
   <meta charset="UTF-8">
</head>
<body>

 <!-- language: PHP -->
 <?php
     if(isset($_POST['age'])) {
     echo $_POST['age'];
     }
  ?>

  <h1>Fill in the form</h1>

  <form method="POST" action="http://localhost/try/">
      <p>age:</p>
      <input type="text" name="age">
      <input type="submit" name="submit">
  </form>

只需將操作從空更改為該php文件的URL,例如在我的示例action =“ http:// localhost / try /”中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM