I have just started my HTTPREQUEST application and I am trying to set up my php files first.
I have this insert function on my wamp/www/MenuBook/
folder :
<?php
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['table_ID']) && isset($_POST['MenuBook']) && isset($_POST['order_status'])&& isset($_POST['order_date'])&& isset($_POST['order_receipt'])) {
$tableID = $_POST['table_ID'];
$menuBook = $_POST['MenuBook'];
$order_status = $_POST['order_status'];
$order_date = $_POST['order_date'];
$order_receipt = $_POST['order_receipt'];
// inlude db connect class
require_once __DIR__ . '/DBConnect.php';
// connecting to db
$db = new DB_CONNECT();
// mysql inserting a new row
$result = mysql_query("INSERT INTO orderdb(table_ID,MenuBook,order_status,order_date,order_receipt) VALUES('$table_ID', '$menuBook', '$order_status','$order_date','$order_receipt')");
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Order successfully created.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
Now I would like to check if it would insert data into the database using my browser something like this :
localhost/MenuBook/insertOrder.php?$table_ID=003&$MenuBook=01&$order_status=PENDING&$order_date=2013-01-17&$order_receipt=NO
as of now it returns this in the browser:
{"success":0,"message":"Required field(s) is missing"}
Any ideas how I could try and check this?