-1

i have quite problem with article editing. I need to select article and place it to form(title and textarea) yet. But i cant even open it. Can u help me please ? Thanks.

<?php

session_start();

include_once('../includes/conn.php');
include_once('../includes/article.php');

$article= new Article;

if(isset($_SESSION['logged_in'])){
$articles=$article->fetch_all();

 if(isset($_POST['id'])){
  $id=$_POST['id'];

$query=$pdo->prepare('SELECT * FROM articles WHERE article_id=?');
$query->bindValue(1,$id);
$query->execute();
}
?>
<html>
<form action="" method="post" autocomplete="off">
  <input type="text" name="title" value="<?php echo 
  $article['article_title'];?>"/><br/><br/>
  <textarea rows="15" cols="50" value="<?php echo 
  $article['article_content'];?>" name="content"></textarea><br/><br/>
  <input type="submit" value="Add article"/>
 </html>
<?php
} else {
 header('Location: index.php');
}
?>
  • 2
    _But i cant even open **it**..._ Open **what**? – B001ᛦ Dec 11 '17 at 11:30
  • 2
    `textarea` doesn't have a `value` attribute. The text should go between the opening and closing tag. – Federico klez Culloca Dec 11 '17 at 11:30
  • `` – urfusion Dec 11 '17 at 11:33
  • thanks, but it is still opening just empty page :( – Samuel Synak Dec 11 '17 at 11:45
  • It's not really clear what your code is doing or is supposed to be doing. You call a method called `fetch_all`, but you don't do anything with the result - your `$articles` variable isn't used anywhere. After that, you're running a select query without assigning the result to anything - why?. If you're just seeing a blank screen, you've probably got a PHP error - look in your error logs. – iainn Dec 11 '17 at 11:55

1 Answers1

-1

There is no value attribute for textarea you have to place your value between start and end tag of textarea

<?php

session_start();

include_once('../includes/conn.php');
include_once('../includes/article.php');

$article= new Article;

if(isset($_SESSION['logged_in'])){
    $articles=$article->fetch_all();

    if(isset($_POST['id'])){
        $id=$_POST['id'];

        $query=$pdo->prepare('SELECT * FROM articles WHERE article_id=?');
        $query->bindValue(1,$id);
        $query->execute();
    }
?>
<html>
<form action="" method="post" autocomplete="off">
  <input type="text" name="title" value="<?php echo 
  $article['article_title'];?>"/><br/><br/>
  <textarea rows="15" cols="50" name="content"><?php echo 
  $article['article_content'];?></textarea><br/><br/>
  <input type="submit" value="Add article"/>
 </html>
<?php
} else {
 header('Location: index.php');
}
?>
pravindot17
  • 1,199
  • 1
  • 15
  • 32
  • Your answer is wrong, no idea why it got upvoted. Do you have a sockpuppet account, or just a friend who upvotes? – Jay Blanchard Dec 11 '17 at 16:37
  • If you feel something wrong you should mentioned in the comment, and yeah, check my profile before asking such a meaningless question – pravindot17 Dec 12 '17 at 05:32
  • You're mixing MySQL API's so `fetch_all()` will never work. Checking your profile reveals nothing about sockpuppet accounts. Not a meaningless question, not to me. – Jay Blanchard Dec 12 '17 at 12:40