Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php HTML表单赢得';T POST数据($\u POST[]为空)_Php_Html_Forms - Fatal编程技术网

Php HTML表单赢得';T POST数据($\u POST[]为空)

Php HTML表单赢得';T POST数据($\u POST[]为空),php,html,forms,Php,Html,Forms,我的一个html表单没有发布数据,submit按钮尊重action属性并将页面重定向为spected,但出于某种原因,$\u POST[]为空。sonebody能帮我找到这里的问题吗 我已经尝试过使用html方法POST,甚至ajax来处理表单和提交数据,但没有这种情况$_POST[]将始终保持空(这是唯一一个这样做的页面,我有一个表单的精确副本,但没有GET方法,它工作正常 <!doctype html> <html> <head> <meta cha

我的一个html表单没有发布数据,submit按钮尊重action属性并将页面重定向为spected,但出于某种原因,$\u POST[]为空。sonebody能帮我找到这里的问题吗

我已经尝试过使用html方法POST,甚至ajax来处理表单和提交数据,但没有这种情况$_POST[]将始终保持空(这是唯一一个这样做的页面,我有一个表单的精确副本,但没有GET方法,它工作正常

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="nocep-rules.css" rel="stylesheet" type="text/css">
    <?php
session_start();
    $link = mysqli_connect("localhost", "xxxx", "xxxx", "xxxxxx");
        if($link === false){
        die("ERROR: Could not connect. " . mysqli_connect_error());
        }

?>
<?php 
    if(!isset($_SESSION['logged'])){
        header("location: /bubale/login.php");
    }
    ?>
</head>


<body>


    <div class="header">

    <img class="logo" src="/bubale/img/logo1.png" alt="" />
    <img class="foro-title" src="/bubale/img/loja_title.png" alt="" />
</div>  

<div class="menu">

  <nav class="site-nav">
       <ul>
          <li><a href="/bubale/logged_user.php">HOME</a></li>
          <li><a href="/bubale/lojacart.php">LOJA</a></li> 
          <li><a href="/bubale/forum2/main_foro.php">FORUM</a></li>
          <li><a href="#">CHECKOUT</a></li>
          <li><a href="/bubale/index.php?logout">SAIR</a></li>

       </ul>
  </nav>

</div>

<div class="info">
        <table width="100%">

        <tr>
          <td width="20%">
     <h2 class="text">USUÁRIO:</h2>
     <?php echo $_SESSION['logged']; ?>
     <h2 class="text2">PONTOS:</h2>
     <?php 

        $sql5= "Select points from profile where user = '".$_SESSION['logged']."'";
        $result5 = mysqli_query($link, $sql5);
        if(mysqli_num_rows($result5)==1){
        while($row5 = mysqli_fetch_assoc($result5)) {
        echo  $row5['points'];

    }
                }
                        ?>
            </td>       
          <td width="30%">
            <?php   
        $sql2= "select * from bolsinhas where user = '".$_SESSION['logged']."' && rev_id = '0'";
        $result2 = mysqli_query($link, $sql2);
        $count = mysqli_num_rows($result2);
        ?>

                <a href="/bubale/forum_bolsinhas/bolsinhas_rev.php"><h2 class="text">BOLSINHAS:</h2></a>
        <?php echo $count; ?>

                <a href="/bubale/forum_prod/produtos.php"><h2 class="text2">PRODUTOS:</h2></a>
        <?php 
        $sql3= "select * from fullsize where user = '".$_SESSION['logged']."' && rev_id = '0'";
        $result3 = mysqli_query($link, $sql3);
        $count3 = mysqli_num_rows($result3);

        echo $count3;

        ?>
            </td>
          <td>
                <?php 
                if(!empty($_SESSION["shopping_cart"])) {
$cart_count = count(array_keys($_SESSION["shopping_cart"]));

}else{$cart_count = "0";}
?>
                <a href="/bubale/cart.php"><img id="icon1" src="img/basket.png" title="Compras" ></a><span id = "count_wrapper"><a id="count">
                <?php echo $cart_count; ?></a></span>
                <a href="#"><img class="icon" src="img/sale.png" title="Promoção" alt="" ></a>
                <a href="#"><img class="icon" src="img/points.png" title="Fidelidade Buba'le" alt="" ></a>

            </td>
        </table>



    </div>

<h1 class="frete">FRETE:</h1>
    <div class="wrapper_frete">
        <?php 

                            $rua1 = $_GET['1'];
                            $numero1 = $_GET['2'];
                            $apt1 = $_GET['3'];
                            $cep1 = $_GET['4'];

                            ?>


        <table id="forma_frete" width="100%">
            <tbody>
                <th>DADOS PESSOAIS</th>
                <th>OOPS!!!</th>

            <tr>
              <form id="modform" method="POST" action="nocep2.php">
                <td width="40%" class="td2">
                    <table id="nested" width="100%">
                        <tr>
                            <td id="td-nested-left" width="30%">
            <label class="label-form" for="user">USUÁRIO:</label><br>
            <label class="label-form" for="rua">RUA:</label><br>
            <label class="label-form" for="numero">NÚMERO:</label><br>
            <label class="label-form" for="apt">APT:</label><br>
            <label class="label-form" for="cep">CEP:</label><br>

                            </td>


                            <td id="td-nested-right">
                            <input name="user" form="buttons" type="text" maxlenght="20" disabled value="<?php echo $_SESSION['logged'];  ?>" /><br>
                            <input name="rua" form="buttons" type="text" value="<?php echo $rua1; ?>" /><br>
                            <input name="numero" form="buttons" type="text" value="<?php echo $numero1;?>" /><br>
                            <input name="apt" form="buttons" type="text" value="<?php echo $apt1; ?>" /><br>
                            <input name="cep" form="buttons" type="text" value="<?php echo $cep1;?>" /> 
                            </td>
                        </tr>
                    </table>
                  <input type="submit" class="refresh" value="ATUALIZAR">
            </td>
                </form>  

                <td id="td_mensage">

                <h3 id="mensage">-irrelevant text-. </h3>   

                </td> 

                </tr>
              <tr>
                <td id="td_ob" colspan="2">
                    <h3 id="comentario">OBSERVAÇAÕ:</h3>
                    <textarea form="buttons" name="observacion" id="text_ob" placeholder="Deixe aqui sua observaçaõ..."></textarea>

                  </td>
          </tr>             
            </tbody>
      </table>


    </div>



<h1 class="frete">SUA COMPRA:</h1>  
<?php
if(isset($_SESSION["shopping_cart"])){
    $total_price = 0;
?>
<?php } ?>

<table class="table">
  <tbody>
    <tr>
      <th></th>
      <th>PRODUTO</th>
      <th>QUANTIDADE</th>
      <th>VALOR UNITARIO</th>
      <th>VALOR TOTAL</th>
    </tr>
    <?php       
foreach ($_SESSION["shopping_cart"] as $product){
?>
    <tr>
      <td id="imgtd"><img src='<?php echo $product["image"]; ?>' width="90" height="80" /></td>
      <td><?php echo $product["name"]; ?><br />
        <form method='post' action=''>
          <input type='hidden' name='code' value="<?php echo $product["code"]; ?>" />
        </form></td>
      <td><form method='post' action=''>
        <input type='hidden' name='code2' value="<?php echo $product["code"]; ?>" />
        <?php echo $product["quantity"];?>
      </form></td>
      <td><?php echo "R$".$product["price"]; ?></td>
      <td><?php echo "R$".$product["price"]*$product["quantity"]; ?></td>
    </tr>
    <?php
$total_price += ($product["price"]*$product["quantity"]);
}

?>

    <tr>
      <td class="td_tot" colspan="5" align="right"><strong id="total">TOTAL: <?php echo "R$".$total_price; ?></strong></td>
    </tr>

  </tbody>
</table>

<form method="post" action="contact-venta.php" id="buttons">
    <?php 


    ?>
    <input type="hidden" name="compras" value="<?php echo print_r($_SESSION["shopping_cart"], TRUE);  ?>"/>
    <input type="hidden" name="total" value="<?php echo $total_price; ?>">

           <input type="submit" id="submit" value="ENVIAR">
</form>


    <?php mysqli_close($link); ?>

</body>
</html>

无标题文件
USUÁRIO: 庞托斯: 护墙板 哎呀!!! USUÁRIO:
RUA:
NÚMERO:
APT:
CEP:

你的HTML相当混乱

首先,
不是
中的有效元素。浏览器正在将它们呈现在表外,并与
分开。请将表单标记移到
内,或将它们移到

乙二醇


或者,如果您需要将表单分散在多个单元格上:

<form method="POST">
<table>
<tr>
  <td>
      <input type="text" name="inputName1">
  </td>
  <td>
      <input type="text" name="inputName2">
  </td>
  <td>
      <input type="submit">
  </td>
</tr>
</table>
</form>


其次,您正在创建许多类型为“hidden”的
元素,每个都有自己的表单标记,因此它们都是不同表单的一部分。请重新排序代码,使隐藏元素与其他

显示在同一
中。请在发布代码之前正确缩进代码,阅读起来很痛苦。不确定是什么原因导致代码为空,但不应调用
se在任何HTML内容之后调用session\u start()
。尝试在HTML之前调用session\u start()
,然后尝试访问
$\u POST
。哪个表单不起作用?第一个表单的提交值为ATUALIZAR…和5个输入(用户、rua、数字、apt和cep)您已将所有输入设置为指向form='buttons'我没有意识到我的输入指向form buttons…这似乎就是问题所在。我重新整理了html代码,现在我们正在工作
<form method="POST">
<table>
<tr>
  <td>
      <input type="text" name="inputName1">
  </td>
  <td>
      <input type="text" name="inputName2">
  </td>
  <td>
      <input type="submit">
  </td>
</tr>
</table>
</form>