首页 > 解决方案 > 如何修复未发送的 POST 方法

问题描述

好的 !当我尝试 "<p> <?php echo $_POST['pseudo'] ?> </p>"注册页面上的代码时,女巫出现在这个之前:我没有得到我的 php 伪显示。

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Mantra</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="/style.css">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">


    <meta http-equiv="X-UA-Compatible" content="ie=edge">
  </head>
  <body>
    <?php include('function.php'); ?>
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ?>
    <style>

      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #map {
        height: 90%;
        width:100%;
      }
      #button_go{
        margin:auto;
      }
      .Profile_picture{
        position: relative;
        margin:auto;
        text-align:center;
        width:75px;
        height:75px;
        border-radius: 50%;
        left: ;
        bottom:45px;
      }

      .container{
        margin-top: -42px;
        margin-bottom: ;
      }
      .cube_droite{
        position: absolute ;
        text-align: center;
        right: 50px ;
        width:300px;
        height: 350px;
        top: 630px;
        background-color: #a9c1c5;
      }
      select{
        background-color: #00cc66;
      }

      #link_validation{
        margin-top: 10px;
      }
    </style>



      <!-- Rectangle d'annotations d'information -->

    <div class="cube_droite">
      <!-- Photo de profil -->
      <img width="550px" height="150px" src="img/profile.jpg" alt="Profile_picture" class="Profile_picture">


      <!-- Call the php database register information -->

      <div class="container">
          </br>
          <div id="link_localisation">

         <button type="button" name="button" onclick="get_pos()">Geolocalise me !</button>  </div>

            <?php echo  $_POST['pseudo']  ?>



          </br>
            <label>Say more about yourself: <input id="personal_information"  type="text" ></input></label>
            <label>Ou travaillez vous ?
            <input type="text" id="position_lat" placeholder="Latitude"> </input>
            <input type="text" id="position_lng" placeholder="Longitude">  </input>
        </br>    ou</br>

            <input type="text" id="position_ville" placeholder="Ville">  </input>
        <div id="link_validation">

       <button type="button" name="button" onclick="get_pos()">valide</button>  </div>
            </label>
</div>
</div>

          <div id="map">  </div>




          <script>


          var map;

          var contentString = 'Montreal';


          function get_pos(){


              let coordinate = new google.maps.LatLng(parseInt(document.getElementById("position_lat").value), parseInt(document.getElementById("position_lng").value))

              // The marker, positioner
              let marker = new google.maps.Marker({position: coordinate, map: map});

              console.log(coordinate)

              console.log(parseFloat(document.getElementById("position_lat").value))}



















              // Initialize and add the map
              function initMap() {
                // The location of Uluru
              var uluru = {lng: -73.460472, lat:45.476861};
                // The map, centered at Uluru
              map = new google.maps.Map(
                    document.getElementById('map'), {zoom: 4, center: uluru});

                    console.log(map)
              }

















          </script>
          <!--Load the API from the specified URL
          * The async attribute allows the browser to render the page while the API loads
          * The key parameter will contain your own API key (which is not needed for this tutorial)
          * The callback parameter executes the initMap() function
          -->
          <script async defer
          src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCCbPf2erpAkX_VgYx4xGtrf_olrxDsvKY&callback=initMap">
          </script>

  </body>
</html>

有人可以帮忙吗?

啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊

标签: phppostmethods

解决方案


内容的文件是否与"<p> <?php echo $_POST['pseudo'] ?> </p>"index.php相同?

您的提交按钮必须在元素中

一切都在 index.php 中:

<?php
if(isset($_POST) && !empty($_POST))
{
    echo "My Name is: ". $_POST['pseudo']. "<br><br>";
}
?>

<form class="" action="index.php" method="post">
  <label>Nom:
      <input type="text" name="pseudo" value="">
  </label>
  <input type="submit" name="submit">
</form>

看起来像这样: 在此处输入图像描述


推荐阅读