Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_GET['post_id']){
- $get_id = $_GET['post_id'];
- $get_post = "select * from `posts` where post_id='$get_id'";
- $run_post = mysqli_query($con,$get_post);
- $row = mysqli_fetch_array($run_post);
- if($row['user_id'] == $user_id){
- $post_title = $row['post_title'];
- $post_content = $row['post_content'];
- }
- else{
- die("<s>}{@керам тут не місце!</s><h1>Відмовлено в доступі...</h1>");
- }
- }
- ?>
- <form action="" method="post" onsubmit="texarea()">
- <h2>Редагувати допис:</h2><br>
- <input type="text" value="<?=$post_title?>" name="title" class="form_control" id="title_text" placeholder="Введіть заголовок">
- <button class="btn_smiles" id="btn_smiles"></button>
- <input type="text" name="content" id="textarea"/>
- <select name="topic" class="form_control" required>
- <option>Виберіть тему</option>
- <?php getTopics(); ?>
- </select>
- <button name="update" class="btn">Редагувати допис</button>
- </form>
- <?php
- if(isset($_POST['update'])){
- $title = $_POST['title'];
- $content = $_POST['content'];
- if(!$title){
- echo"Прблема з title!";
- }
- if(!$content){
- echo"Прблема з content!";
- }
- $update_post = "update `posts` set post_title='$post_title' where post_id='$get_id'";
- $run_post = mysqli_query($con,$update_post);
- if(!$run_post){
- echo"Прблема з run_post!";
- }
- if($run_post){
- echo"<script>alert('Ваш пост оновлено!');</script>";
- // echo"<script>window.open('home.php','_self');</script>";
- }
- else{
- echo"<script>alert('Ваш пост НЕ оновлено...');</script>";
- // echo"<script>window.open('home.php','_self');</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment