Toby Chui пре 5 година
родитељ
комит
d787e0a0a3
4 измењених фајлова са 27 додато и 3 уклоњено
  1. 4 0
      TC/autopush.bat
  2. 13 1
      src/requestDB.php
  3. 9 2
      src/updateSql.php
  4. 1 0
      src/userdata/cookieseeds/1573019294.auth

+ 4 - 0
TC/autopush.bat

@@ -0,0 +1,4 @@
+cd ../
+git add *
+git commit -m "TC:autopush funct"
+git push

+ 13 - 1
src/requestDB.php

@@ -1,5 +1,5 @@
 <?php
-
+//Pass query to database and return something
 function query($query,$table){
 	$conn = mysqli_connect("localhost","teabag","teabagpassword",$table);
 	if($conn->connect_error)
@@ -21,6 +21,18 @@ function query($query,$table){
 	$conn->close();
 } 
 
+//Write things to database without returning anything
+function queryw($query,$table){
+	$conn = mysqli_connect("localhost","teabag","teabagpassword",$table);
+	if($conn->connect_error)
+	{
+		echo "Unable to connect to database";
+		exit;
+	}
+	$result = $conn->query($query);
+	return 0;
+}
+
 //Test Code, uncomment this section if you want to test query function with javascript, not recommended
 /*
 if (isset($_GET['query']) && isset($_GET['table'])){

+ 9 - 2
src/updateSql.php

@@ -1,5 +1,12 @@
 <?php
-session_start();
+include_once(__DIR__ . "/auth.php");
+include_once("requestDB.php");
+if (isset($_POST["message"])){
+	queryw("INSERT INTO `post` (`postid`, `username`, `content`, `posttime`) VALUES (NULL, '" . $_SESSION['login'] . "', '" . $_POST["message"] . "', CURRENT_TIMESTAMP)","teabag");
+}
+header("Location: index.php");
+
+/*
 $conn = mysqli_connect("localhost","root","","message");
 if($conn->connect_error)
 {
@@ -17,5 +24,5 @@ $stmt->close();
 $conn->close();
 
 header("Location: index.php");
-
+*/
 ?>

+ 1 - 0
src/userdata/cookieseeds/1573019294.auth

@@ -0,0 +1 @@
+cc25b07d5a73801f6cb330d24b1f6b9adb4f4ca30d8188cf01af5a774fa20902464099b6d36fe58d60637981f0104d4ff25c895d1e3628f3442767002e5676b2