aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-09-28 19:14:53 +0200
committerMateja <mail@matejamaric.com>2020-09-28 19:14:53 +0200
commit00fda2f0dfdaa1129949f0fa116cfaeff23ab486 (patch)
tree7ff6596f038c84771484da6c8150ce441aad89c6 /test
downloadold-php-yota-00fda2f0dfdaa1129949f0fa116cfaeff23ab486.tar.gz
old-php-yota-00fda2f0dfdaa1129949f0fa116cfaeff23ab486.zip
first commit
Diffstat (limited to 'test')
-rw-r--r--test/edit.inc.php7
-rw-r--r--test/test.inc.php4
-rw-r--r--test/test.php34
-rw-r--r--test/test2.php56
4 files changed, 101 insertions, 0 deletions
diff --git a/test/edit.inc.php b/test/edit.inc.php
new file mode 100644
index 0000000..cb0c23f
--- /dev/null
+++ b/test/edit.inc.php
@@ -0,0 +1,7 @@
+<?php
+/*
+if (isset($_POST['subvar'])) {
+ echo $_POST['subvar'];
+}
+*/
+echo $_POST['action'];
diff --git a/test/test.inc.php b/test/test.inc.php
new file mode 100644
index 0000000..853270c
--- /dev/null
+++ b/test/test.inc.php
@@ -0,0 +1,4 @@
+<?php
+if (isset($_POST['your-submit'])) {
+ # echo $_POST['your-submit'];
+}
diff --git a/test/test.php b/test/test.php
new file mode 100644
index 0000000..5bca6ac
--- /dev/null
+++ b/test/test.php
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width initial-scale=1.0"/>
+ <link href="../style.css" rel="stylesheet" type="text/css"/>
+ <title>Test</title>
+</head>
+<body>
+<main>
+<?php
+if($_SERVER["REQUEST_METHOD"] == "POST") {
+ $email = clear_input($_POST['name']);
+ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ echo "You fucking bitch!<br>";
+ } else {
+ echo "You oki: " . $email . "<br>";
+ }
+}
+function clear_input($data) {
+ $data = trim($data);
+ $data = stripslashes($data);
+ $data = htmlspecialchars($data);
+ return $data;
+}
+include 'test.inc.php';
+?>
+<form method="POST">
+<input type="text" name="name">
+<input type="submit" name="your-submit" value="Submit">
+</form>
+</main>
+</body>
+</html>
diff --git a/test/test2.php b/test/test2.php
new file mode 100644
index 0000000..8f2c697
--- /dev/null
+++ b/test/test2.php
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<title>Test table</title>
+<style>
+ table {
+ border-collapse: collapse;
+ }
+ th, td {
+ border: 1px solid black;
+ padding: 0.2rem;
+ }
+</style>
+
+<script>
+function subAction(action) {
+ var xhttp = new XMLHttpRequest();
+ /*
+ xhttp.onreadystatechange = function() {
+ if(this.readyState == 4 && this.status == 200) {
+ console.log(this.responseText);
+ }
+ }
+ */
+ xhttp.onload = function() {
+ console.log(this.responseText);
+ }
+ xhttp.open("POST", "edit.inc.php", true);
+ xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhttp.send("action=" + action);
+}
+</script>
+
+</head>
+<body>
+<?php
+try {
+ $conn = new PDO("mysql:host=localhost;dbname=testdb", "testuser", "testpass");
+ echo "<table>\n";
+ echo "<tr><th>Name</th><th>Actions</th></tr>\n";
+ foreach ($conn->query("SELECT * FROM tbl1") as $row) {
+ echo "<tr><td contenteditable=\"true\">" . $row['name'] . "</td>";
+ echo "<td>";
+ echo "<button onclick=\"subAction('save')\">Save</button>";
+ echo "<button onclick=\"subAction('delete')\">Delete</button>";
+ echo "</td></tr>\n";
+ }
+ echo "</table>\n";
+}
+catch (PDOException $e) {
+ echo $e->getMessage();
+}
+?>
+</body>
+</html>