Hello to all. Tell me, I made a file with the addition of news from the video lesson, but the trouble is ... they did not tell me how to remove it (without phpmyadmin). Here is the code that turned out.

<hr> <html> <center><h1>Новости</h1></center> <hr> <?php if ($_POST['post']) { $title = $_POST['title']; $body = $_POST['body']; if($title&&$body) { mysql_connect("localhost", "admin", "159357") or die(mysql_error()); mysql_select_db("admin") or die(mysql_error()); $date = date("Ymd"); $insert = mysql_query("INSERT INTO news VALUES('','$title','$body','$date')") or die(mysql_error()); die("Новость добавлена"); } else echo "Заполните все поля<p>"; } ?> <center><form action = 'post.php' method = 'POST'> Название : <br> <input type ='text' name='title'><p> Текст : <br> <textarea rows='6' cols='35' name='body'></textarea><p> <input type='submit' name='post' value='Добавить новость'> </form></center> </hr> </html> 

    1 answer 1

    Here it depends on the request, for example:

     mysql_query("DELETE FROM news WHERE id='" .news_id. "'"); 

    So dig in this direction :) And also, what a horrible line it is:

     die("Новость добавлена"); 

    Where did you read this at all? :)

    • 3
      ahaha !!!! die ("News added"); - Artem
    • one
      [ hashcode.ru/users/5119/shamanis[[1] thanks, uplifted ) [1]: http: // @ Shamanis - Palmervan
    • one
      if ($ title && $ body) {... die ("News added"); } else echo "Fill in all the fields <p>"; On the GK, definitely). - ling
    • Guys, if he saw this in a video lesson, then it really becomes scary to me O_o - Shamanis
    • one
      @ Angus123, if you don’t know php, it’s even difficult for you to explain how to do it, although it will be easy to explain, but you don’t understand anything. And no one will write code for you, and if it does, little information is provided anyway. You have already been given a hint in this answer, google. Or download a ready-made news script and do not make your gray matter boil. - Elime