Php 为什么“区域”组合框中的选定项目没有';t添加到我的MySQL数据库中 print\r($\u POST)的结果是什么何时提交表单?另外,您在哪个浏览器中进行测试?请查看此echo$stmt->queryString执行的查询@user790454
为什么“区域”组合框中的选定项目没有';t添加到我的MySQL数据库中Php 为什么“区域”组合框中的选定项目没有';t添加到我的MySQL数据库中 print\r($\u POST)的结果是什么何时提交表单?另外,您在哪个浏览器中进行测试?请查看此echo$stmt->queryString执行的查询@user790454,php,mysql,combobox,Php,Mysql,Combobox,为什么“区域”组合框中的选定项目没有';t添加到我的MySQL数据库中 print\r($\u POST)的结果是什么何时提交表单?另外,您在哪个浏览器中进行测试?请查看此echo$stmt->queryString执行的查询@user790454既然您已经使用它来调试自己的问题,您可能会对我编写此扩展的免责声明感兴趣。我正在使用Google Chrome和print\r($\u POST)没有显示表单将数据提交到哪个页面的值? <?php require("config.inc
print\r($\u POST)的结果是什么代码>何时提交表单?另外,您在哪个浏览器中进行测试?请查看此echo$stmt->queryString执行的查询@user790454既然您已经使用它来调试自己的问题,您可能会对我编写此扩展的免责声明感兴趣。我正在使用Google Chrome和print\r($\u POST)
没有显示表单将数据提交到哪个页面的值?
<?php
require("config.inc.php");
//if posted data is not empty
if (!empty($_POST)) {
if (empty($_POST['name']) || empty($_POST['mobilenumber']) || empty($_POST['address']) || empty($_POST['city']) || empty($_POST['postcode']) || empty($_POST['state'])) {
// Create some data that will be the JSON response
$response["success"] = 0;
$response["message"] = "Please insert information in the required marked ** field.";
die(json_encode($response));
}
else if (empty($_POST['email']) || empty($_POST['password'])) {
// Create some data that will be the JSON response
$response["success"] = 0;
$response["message"] = "Please Enter Both a Username and Password.";
die(json_encode($response));
}
else if (strlen($_POST['password']) < 6) {
$response["success"] = 0;
$response["message"] = "Your password should be at least 6 characters.";
die(json_encode($response));
}
else if ($_POST['password'] != $_POST['confirmpassword']){
$response["success"] = 0;
$response["message"] = "Confirm Password is not the same with Password you have entered.";
die(json_encode($response));
}
else if (strlen($_POST['mobilenumber']) < 10) {
$response["success"] = 0;
$response["message"] = "Your mobile number should be at least 10 characters.";
die(json_encode($response));
}
else if (strlen($_POST['postcode']) != 5) {
$response["success"] = 0;
$response["message"] = "Your postcode can only have 5 numbers.";
die(json_encode($response));
}
$query = " SELECT 1 FROM user WHERE email = :email";
$query_params = array(
':email' => $_POST['email']
);
//Now let's make run the query:
try {
// These two statements run the query against your database table.
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
// For testing, you could use a die and message.
//die("Failed to run query: " . $ex->getMessage());
//or just use this use this one to product JSON data:
$response["success"] = 0;
$response["message"] = "Database Error1. Please Try Again!";
die(json_encode($response));
}
//fetch is an array of returned data. If any data is returned,
//we know that the username is already in use, so we murder our
//page
$row = $stmt->fetch();
if ($row) {
// For testing, you could use a die and message.
//die("This username is already in use");
//You could comment out the above die and use this one:
$response["success"] = 0;
$response["message"] = "I'm sorry, this username is already in use";
die(json_encode($response));
}
$query = "INSERT INTO user ( name, email, password, mobilenumber, address, city, postcode, state, position, cardbalance, zone)
VALUES ( :name, :email, :password, :mobilenumber, :address, :city, :postcode, :state, :position, :cardbalance, :zone) ";
//Again, we need to update our tokens with the actual data:
$query_params = array(
':name' => $_POST['name'],
':email' => $_POST['email'],
':password' => $_POST['password'],
':mobilenumber' => $_POST['mobilenumber'],
':address' => $_POST['address'],
':city' => $_POST['city'],
':postcode' => $_POST['postcode'],
':state' => $_POST['state'],
':position' => $_POST['position'],
':cardbalance' => $_POST['cardbalance'],
':zone' => $_POST['zone']
);
//time to run our query, and create the user
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
// For testing, you could use a die and message.
//die("Failed to run query: " . $ex->getMessage());
//or just use this use this one:
$response["success"] = 0;
$response["message"] = "Database Error2. Please Try Again!";
die(json_encode($response));
}
$response["success"] = 1;
$response["message"] = "Staff Successfully Added!";
echo json_encode($response);
//for a php webservice you could do a simple redirect and die.
//header("Location: login.php");
//die("Redirecting to login.php");
} else {
?>
<h1>Staff Registration</h1>
<form action="register.php" method="post">
Name:<br />
<input type="text" name="name" value="" />
<br /><br />
Email:<br />
<input type="email" name="email" value="" />
<br /><br />
Password:<br />
<input type="password" name="password" value="" />
<br /><br />
Confirm Password:<br />
<input type="password" name="confirmpassword" value="" />
<br /><br />
Mobile Number:<br />
<input type="text" name="mobilenumber" value="" />
<br /><br />
Address:<br />
<input type="text" name="address" value="" />
<br /><br />
City:<br />
<input type="text" name="city" value="" />
<br /><br />
Postcode:<br />
<input type="text" name="postcode" value="" />
<br /><br />
State:<br />
<input type="text" name="state" value="" />
<br /><br />
Position:<br />
<input type="text" name="position" value="staff" readonly/>
<br /><br />
Card Balance:<br />
<input type="text" name="cardbalance" value="0" readonly/>
<br /><br />
Zone Assignation:
<select id='zone' name='zone'>
<option value='1'>A</option>
<option value='2'>B</option>
<option value='3'>C</option>
<option value='4'>D</option>
</select>
<br /><br />
<input type="submit" value="Register New User" />
</form>
<?php
}
?>
<select id='zone' name='zone'>
<option value='1'>A</option>
<option value='2'>B</option>
<option value='3'>C</option>
<option value='4'>D</option>
</select>