0

Here's my updated code after following some of your suggestions, I have lost that error but now my form doesn't output the posts, are there any suggestions for this?

<form method="get" action="wavy.php">
        <textarea name="postbody" rows="8" cols="80"></textarea>
        <input type="submit" value="submit" />
</form>

<?php 
include("connect.php");
$userid = "";
$username = ""; 
$id = "";
    if(isset($_GET['postbody'])) 
    {
        if(isset($_GET['id']))
        {
            if (connect::query('SELECT id FROM accounts')) {
                $userid = connect::query('SELECT id FROM accounts', array(':id'=>$_GET['id']))[0]['id'];
                $postbody = $_GET['postbody'];  

                connect::query('INSERT INTO posts VALUES (null, :postbody, NOW(), :userid, 0)', array(':postbody'=>$postbody, ':userid'=>$userid));   
            }  
            $dbposts = connect::query('SELECT * FROM posts ORDER BY id DESC', array(':userid'=>$userid));
                $posts = "";
                foreach($dbposts as $p) {
                        $posts .= htmlspecialchars($p['body'])."
                        <form action='wavy.php' method='get'>
                                <input type='submit' name='like' value='Like'>
                        </form>
                        <hr /></br />
                        ";
            }    
        }
    }   


    if(isset($postbody))
    {
        echo $postbody;               
    }
?>
abiel
  • 9
  • 4

0 Answers0