-
Notifications
You must be signed in to change notification settings - Fork 0
/
InsertNewOrderForMobileApp.php
54 lines (40 loc) · 2.2 KB
/
InsertNewOrderForMobileApp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include ('GetDataFromDB.php');
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$phoneNo=$_POST[phoneNo];
$firstName=$_POST[firstName];
$lastName=$_POST[lastName];
$userId =$_POST[userId];
$address =$_POST[address];
$orderText = $_POST[orderText];
$imageLocation = $_POST[imageLocation];
$error_status = FALSE;
if (empty($phoneNo) || empty($firstName) | empty($lastName) | empty($userId) | empty($address) ){
$error_status = TRUE;
logToFile(basename(__FILE__)."One of the mandatory value was empty so redirection happened ");
header('Location: http://kosmixenterprises.com');
}
if(empty($orderText) | empty($imageLocation)){
$error_status = TRUE;
logToFile(basename(__FILE__)."One of the mandatory value was empty so redirection happened ");
header('Location: http://kosmixenterprises.com');
}
if(!$error_status){
$connection = new GetDataFromDB(); //i created a new object
$connection->getConnection(); // connected to the database
echo "<br />"; // putting a html break
$connection->selectDatabase();
logToFile(basename(__FILE__)."About to insert into customer table with data ".$_POST[phoneNo] . $_POST[firstName]. $_POST[lastName]. $_POST[userId]. $_POST[address]);
$connection->insertNewCustomer($_POST[phoneNo],$_POST[firstName],$_POST[lastName],$_POST[userId],$_POST[address]);
logToFile(basename(__FILE__)."Data inserted into customer table sucessfully ");
logToFile(basename(__FILE__)."About to insert into order table with data ".$_POST[phoneNo],$_POST[orderText],$_POST[imageLocation]);
$connection->insertNewOrder($_POST[phoneNo],$_POST[orderText],$_POST[imageLocation]);
logToFile(basename(__FILE__)."Inserted into Order table ");
$connection->closeConnection();
}
}