<?php include 'header.php'; if ($_SERVER['REQUEST_METHOD'] == 'GET') { //$newTweet = new Tweet(); $_SESSION['tweetToUpdateId'] = $_GET['updateTweet']; $newTweet = new Tweet(); $newTweet->loadFromDB($conn, $_GET['updateTweet']); echo "Stara treść tweeta: " . $newTweet->getText(); // niezbyt secure - przerobić na metodę POST } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $newTweet = new Tweet(); echo "Tweet zaktualizowany"; $newTweet->udpateTweetInDb($conn, $_SESSION['tweetToUpdateId'], $_POST['tweetUpdatedText']); // zmiana treści Tweeta } echo ' <div class="row"> <div class="col-sm-6 col-md-4 col-md-offset-4"> <!--<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1>--> <div class="account-wall"> <!--<img class="profile-img" src="img/login.jpg"alt="">--> <form class="form-signin" action="edit_tweet.php" method="post"> <h3><legend>Wpisz nowy text Tweeta</legend></h3> <label for="">Treść Tweeta</label><br> <textarea name ="tweetUpdatedText"rows="4" cols="70"></textarea></br> <button type="submit" class="btn btn-lg btn-primary btn-block">Wyslij</button> <span class="clearfix"></span> </form> </div>
<?php include 'header.php'; $tempTweet = new Tweet(); $tempTweet->loadFromDB($conn, $_GET['displayTweet']); $tempTweet->loadUserFromDBforTweet($conn, $_GET['displayTweet']); $tempUser = new User(); $tempUser->loadFromDB($conn, $tempTweet->getId_user()); echo '<div class="container">'; echo "Author: " . $tempUser->getName(); echo "<hr>"; echo $tempTweet->getText(); echo "<hr>"; if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['comment'])) { $tempComment = new Comments(); $tempComment->saveCommentsToDb($conn, $_SESSION['user_id'], $_GET['displayTweet'], $_POST['comment']); // $tempComment = null; } //if(!isset($tempComment)){ // $tempComment = new Comments(); // }; echo "<h4>Komentarze:</h4>"; //echo ("<hr>"); $retArray = $tempTweet->getAllComments($conn); echo "<br>"; foreach ($retArray as $comment) { ?> <br> <div class = 'text-center'> <?php echo $comment->getText();
</div> </nav> <div class="row"> <div class="col-sm-4"> </div> <div class="col-sm-4"> <table class="table table-striped"> <tr> <th>Wpis:</th> </tr> <tr> <td> <!-- Wyświetla treść wpisu, którego dotyczy wyświetlana strona --> <?php echo $tweet->getText(); ?> </td> </tr> </table> <form role="form" action="show_tweet.php" method="post"> <div class="form-group"> <textarea name="comment_text" class="form-control" rows="2" maxlength="60" placeholder="Wpisz treść komentarza."></textarea> <!-- Tekst przechowywany w tej zmiennej umożliwia wyświetlanie wciąż tej samej storny, po dodaniu komentarza --> <input type="hidden" name="tweet_text" value="<?php echo $_GET['tweet_text']; ?> "> </div> <button type="submit" class="btn btn-default">Dodaj</button>