Esempio n. 1
0
<?php

require_once "edit_functions.php";
//kas kasutaja uuendab andmeid
if (isset($_POST["update"])) {
    updatePost($_POST["id"], $_POST["post_title"], $_POST["post"]);
}
if (!isset($_GET["view"])) {
    //kui aadressi real ei ole ?view=, suuname table lehele
    header("location: table2.php");
} else {
    //küsime andmebaasist andmed id järgi
    $post_object = getSinglePostData($_GET["view"]);
    //var_dump($post_object);
}
?>

<?php 
$page_title = "view";
$file_name = "view.php";
?>

<?php 
require_once "../header.php";
?>

<h2><?php 
echo $post_object->post_title;
?>
</h2>
<p style="width: 500px; padding: 10px; border: 1px solid gray;"><?php 
Esempio n. 2
0
<?php

require_once "edit_functions.php";
//kas kasutaja uuendab andmeid
if (isset($_POST["update"])) {
    updatePost($_POST["id"], $_POST["post_title"], $_POST["post"]);
}
if (!isset($_GET["edit"])) {
    //kui aadressi real ei ole ?edit=, suuname table lehele
    header("location: table.php");
} else {
    //küsime andmebaasist andmed id järgi
    $post_object = getSinglePostData($_GET["edit"]);
    //var_dump($post_object);
}
//id mida muudame
//echo $_GET["edit"];
//vaja saada kätte kõige uuemad andmed id kohta
?>

<h2>Change Post</h2>
  <form action="<?php 
echo htmlspecialchars($_SERVER["PHP_SELF"]);
?>
" method="post" >
	<input type="hidden" name="id" value="<?php 
echo $_GET["edit"];
?>
">
  	<label for="post_title" >Title</label><br>
	<input id="post_title" name="post_title" type="text" value="<?php