Im trying to post data and put it into a msql database but when i put do print_r($_POST); it shows the array as empty. I know its getting the value correctly however its not posting
<!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>
Below is the php page that is getting the post however it shows array() as blank. There also isnt any errors reporting.
<?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");
});
Your <input> tag needs name attribute. it'll be used to be index in your $_POST, so, this input:
<input name="some" type="text"/>
will produce:
$_POST['some']
http://www.w3schools.com/php/php_post.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With