gpt4 book ai didi

php - HTML 表单不发布

转载 作者:太空宇宙 更新时间:2023-11-04 13:36:26 26 4
gpt4 key购买 nike

我试图发布数据并将其放入 msql 数据库,但是当我执行 print_r($_POST);它显示数组为空。我知道它正确地获取了值但是它没有发布

  <!DOCTYPE html>

<html>

<head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="Scripts/menu.js"></script>
<script src="Scripts/signup.js"></script>

<link rel='stylesheet' href='CSS/index.css'>


</head>

<body>

<img src="wc.png" id="wc">

<img src='restaurant.jpg' id="restaurant">
<img src='map.jpg' id="map">
<img src='mail.jpg' id="mail">
<img src='people.jpg' id="people">

<div id="window"> <div id="membersWindow"> <input type="text" id="signupUsername" value="name" placeholder="Username">

<form action="/signup.php" method="post">
<input type="password" id="signupPassword" placeholder="Password">

<input type="text" id="signupEmail" placeholder="Email">

<input type="text" id="signupphoneNumber" placeholder="Phone Number">

<iframe src="useragreement.html" id="userAgreement"> </iframe>

<input type="submit" id="signupSubmit">
</div>

</form>

<div id="restaurantWindow"> Restaurant Window </div>

<!--- <div id="mapWindow"> <iframe src="https://maps.google.com/?ie=UTF8&amp;ll=29.817178,-95.401291&amp;spn=0.689868,1.256561&amp;t=h&amp;z=10&amp;output=embed"></iframe>
</div> --->

<div id="mailWindow"> Mail Window </div>

</div>

<div id="banner"> <h1> Wolfeboro Connection </h1> </div>

</body>

</html>

下面是获取帖子的 php 页面,但它显示 array() 为空白。也没有任何错误报告。

<?php
error_log(E_ALL);

if( isset($_POST) ) echo "NO POST<BR>";
print_r($_POST);



include("connection.php");



$stmt = $db->stmt_init();

if($stmt->prepare("INSERT INTO users (BusinessName, Password, Phone, Email ) VALUES (?, ?, ?, ?)")) {

$stmt->execute();
$stmt->close();

}



?>


$(function()
{
alert($("#signupUsername").val());

$("#signupSubmit").click(function() {
alert("posting "+$("#signupUsername").val());

$.post( "../signup.php",
{ username: $("#signupUsername").val(),
password: $("#signupPassword").val(),
phonenumber: $("#signupphoneNumber").val(),
email: $("#signupEmail").val()
})
.done( function(r)
{
alert("done");
})
.fail( funciton()
{
alert("fail");
});
});
alert("loaded");

});

最佳答案

你的 <input>标签需要 name属性。它将被用作您的 $_POST 中的索引,所以,这个输入:

<input name="some" type="text"/>

将产生:

$_POST['some']

http://www.w3schools.com/php/php_post.asp

关于php - HTML 表单不发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15671908/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com