From 804c8daa8896fbf08b58000dc15fd35526c76bde Mon Sep 17 00:00:00 2001 From: thealgorithm Date: Wed, 28 Sep 2016 20:02:45 +0200 Subject: [PATCH 1/2] SQLite Implementierung --- connlite.php | 31 ++++++++++++++++ myform2.php | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 connlite.php create mode 100644 myform2.php diff --git a/connlite.php b/connlite.php new file mode 100644 index 0000000..bbed1f8 --- /dev/null +++ b/connlite.php @@ -0,0 +1,31 @@ +open('test.db'); + } + } + + + $db = new MyDB(); + if(!$db){ + echo $db->lastErrorMsg(); + } else { + // echo "Opened database successfully\n"; + } + + $create_qry ="CREATE TABLE IF NOT EXISTS blogpost(id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL DEFAULT '0', + message TEXT NOT NULL DEFAULT '0', + timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)"; + + + $ret = $db->exec($create_qry); + if(!$ret){ + echo $db->lastErrorMsg(); + } else { + // echo "Table created successfully"; + } + +?> diff --git a/myform2.php b/myform2.php new file mode 100644 index 0000000..b81af01 --- /dev/null +++ b/myform2.php @@ -0,0 +1,100 @@ + + +You forgot to enter your name!"; + }else{ + $errorMessage .= "
  • You forgot to enter your blogpost!
  • "; + } + }else{ + $varName = $_POST['name']; + $varBlogpost = $_POST['blogpost']; + + + + echo ("
    "); + echo ("
    "); + + $mysql_qry = "INSERT INTO blogpost (name,message) VALUES ('$varName', '$varBlogpost')"; + + $result = $db->exec($mysql_qry); + + if(!$result){ + echo $db->lastErrorMsg(); + }else{ + // echo "Records created successfully"; + } + + } + + + + + if(!empty($errorMessage)) + { + echo("

    there was an error with your form:

    \n"); + echo("\n"); + } + } + + + +?> + + +
    + + +
    +

    + + +
    + +query($sql_qry_all); + + + + + while ($row2 = $ret2->fetchArray(SQLITE3_ASSOC)){ + $deleteIndexString = "delete".$row2['id']; + echo "Name: " . $row2["name"] ."
    "; + echo "Blogeintrag: " . $row2["message"] . "
    "; + echo "Erstellungszeitpunkt: " . $row2["timestamp"] . "
    "; + $arr = str_split($deleteIndexString,6); + echo '
    '; + echo "

    "; + echo '
    '; + } + + $index = ""; + if(!empty($_GET)){ + $deleteIndexString = $_GET['delete']; + $arr2 = explode(" ", $deleteIndexString); + echo $arr2[1]; + $index = $arr2[1]; + } + + + + $sql_qry_delete =<<query($sql_qry_delete); + + + + + + ?> From 47c036674a9c785568c0da73e2b5038587af6fec Mon Sep 17 00:00:00 2001 From: thealgorithm Date: Wed, 28 Sep 2016 20:42:59 +0200 Subject: [PATCH 2/2] neue Ordnerstruktur --- conntest.php => Exc1 SQL/conntest.php | 0 myform.php => Exc1 SQL/myform.php | 0 connlite.php => Exc1 SQLite/connlite.php | 0 myform2.php => Exc1 SQLite/myform2.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename conntest.php => Exc1 SQL/conntest.php (100%) rename myform.php => Exc1 SQL/myform.php (100%) rename connlite.php => Exc1 SQLite/connlite.php (100%) rename myform2.php => Exc1 SQLite/myform2.php (100%) diff --git a/conntest.php b/Exc1 SQL/conntest.php similarity index 100% rename from conntest.php rename to Exc1 SQL/conntest.php diff --git a/myform.php b/Exc1 SQL/myform.php similarity index 100% rename from myform.php rename to Exc1 SQL/myform.php diff --git a/connlite.php b/Exc1 SQLite/connlite.php similarity index 100% rename from connlite.php rename to Exc1 SQLite/connlite.php diff --git a/myform2.php b/Exc1 SQLite/myform2.php similarity index 100% rename from myform2.php rename to Exc1 SQLite/myform2.php