Commit b4c4c11c authored by Ayush's avatar Ayush

Minor fixes

parent 8bf265b9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Credentials: true');
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE"); header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8"); header("Content-Type: application/json; charset=UTF-8");
...@@ -12,7 +12,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET'){ ...@@ -12,7 +12,7 @@ if($_SERVER['REQUEST_METHOD'] === 'GET'){
$sql1 = "SELECT Now()"; $sql1 = "SELECT Now()";
$currtime = $mysqli->query($sql1); $currtime = $mysqli->query($sql1);
$sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime"; $sql2 = "SELECT * FROM questions WHERE stime <= $currtime and etime >= $currtime";
$data = []; $data = [];
if($result = mysqli->query($sql2)){ if($result = mysqli->query($sql2)){
while($row = mysql_fetch_assoc($request)){ while($row = mysql_fetch_assoc($request)){
...@@ -25,4 +25,4 @@ if($_SERVER['REQUEST_METHOD'] === 'GET'){ ...@@ -25,4 +25,4 @@ if($_SERVER['REQUEST_METHOD'] === 'GET'){
} }
} }
?> ?>
\ No newline at end of file
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Credentials: true');
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE"); header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8"); header("Content-Type: application/json; charset=UTF-8");
include_once("../database.php"); include_once("../database.php");
$postData = file_get_contents("php://input"); $postData = file_get_contents("php://input");
echo $postData;
exit(0);
if(isset($postData) && !empty($postData)){ if(isset($postData) && !empty($postData)){
$request = json_decode($postData); $request = json_decode($postData);
$title = trim($request->title); $title = trim($request->title);
$username = trim($request->username); //string $username = trim($request->username); //string
$statement = trim($request->statement); //string $statement = trim($request->statement); //string
...@@ -20,7 +23,7 @@ if(isset($postData) && !empty($postData)){ ...@@ -20,7 +23,7 @@ if(isset($postData) && !empty($postData)){
$tc2 = trim($request->tc2_inp); $tc2 = trim($request->tc2_inp);
$out2 = trim($request->tc2_out); $out2 = trim($request->tc2_out);
$stime = trim($request->start_time); //string $stime = trim($request->start_time); //string
$etime = trim($request->end_time) $etime = trim($request->end_time);
$sql = "INSERT INTO questions(title,username,statement,tc1,out1,tc2,out2,stime,etime) VALUES ('$title','$username','$statement','$tc1','$out1','$tc2','$out2','$stime','$etime')"; $sql = "INSERT INTO questions(title,username,statement,tc1,out1,tc2,out2,stime,etime) VALUES ('$title','$username','$statement','$tc1','$out1','$tc2','$out2','$stime','$etime')";
...@@ -35,4 +38,4 @@ if(isset($postData) && !empty($postData)){ ...@@ -35,4 +38,4 @@ if(isset($postData) && !empty($postData)){
} }
?> ?>
\ No newline at end of file
...@@ -16,6 +16,7 @@ export class QuestionService { ...@@ -16,6 +16,7 @@ export class QuestionService {
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
uploadQues(ques: Question): Observable<any> { uploadQues(ques: Question): Observable<any> {
console.log(ques);
return this.http.post(this.uploadUrl, ques); return this.http.post(this.uploadUrl, ques);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment