Php HTML表单未发布
我试图发布数据并将其放入msql数据库,但当我发布do print\r($\u post)时;它将数组显示为空。我知道它得到正确的价值,但它没有张贴Php HTML表单未发布,php,html,Php,Html,我试图发布数据并将其放入msql数据库,但当我发布do print\r($\u post)时;它将数组显示为空。我知道它得到正确的价值,但它没有张贴 <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="Scripts/menu.js">&
<!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&ll=29.817178,-95.401291&spn=0.689868,1.256561&t=h&z=10&output=embed"></iframe>
</div> --->
<div id="mailWindow"> Mail Window </div>
</div>
<div id="banner"> <h1> Wolfeboro Connection </h1> </div>
</body>
</html>
餐厅橱窗
邮件窗口
Wolfeboro连接
下面是收到帖子的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");
});
$(函数()
{
警报($(“#注册用户名”).val();
$(“#signupSubmit”)。单击(函数(){
警报(“发布”+$(“#注册用户名”).val();
$.post(“../signup.php”,
{用户名:$(“#注册用户名”).val(),
密码:$(“#signupPassword”).val(),
电话号码:$(“#signupphoneNumber”).val(),
电子邮件:$(“#注册电子邮件”).val()
})
.完成(功能(r)
{
警惕(“完成”);
})
.fail(函数()
{
警报(“失败”);
});
});
警报(“已加载”);
});
您的
标记需要名称
属性。它将被用作$\u帖子中的索引,因此,此输入:
<input name="some" type="text"/>
您必须为所有输入
指定一个名称
属性,该属性将向数组中添加值:
<form action="/signup.php" method="post">
<input type="password" id="signupPassword" placeholder="Password">
<input type="text" name="signupEmail" placeholder="Email">
<input type="text" name="signupphoneNumber" placeholder="Phone Number">
<input type="submit" name="signupSubmit">
</form>
您还可以使用“HTTPFox”-Firefox插件来获取所有请求,包括用于调试的所有get/POST信息。这非常有用:)jQuery和AJAX在哪里发挥作用?这只是您展示的一个基本HTML表单。很抱歉,我提交了其余的代码
<form action="/signup.php" method="post">
<input type="password" id="signupPassword" placeholder="Password">
<input type="text" name="signupEmail" placeholder="Email">
<input type="text" name="signupphoneNumber" placeholder="Phone Number">
<input type="submit" name="signupSubmit">
</form>