php - Code inside if statements won't execute, why won't post and get methods set? -


here's code, @ first had undefined index notice postimg (the input variable in form) in foreach() loop, got rid of notice checking if postimg set, posts , images won't show up, debugged code find nothing in if statements being executed, why post , not getting set?

<?php  include("connect.php");  include("check.php"); include("image.php"); $postbody = ""; $posts = ""; //$postimg = "";       if (isset($_post['post'])) {     //  $time = connect::query('select posted_at dry_posts id=:postid', array(':postid'=>$_get['id']));     //$postimg = $_post['postimg']     //if(isset($_post['postimg'])) {            //$id = connect::query('select id dry_posts id=:id', array(':id'=>$_get['id']));             if ($_files['postimg']['size'] == 0) {                 $postbody = $_post['postbody'];                 $loggedinuserid = check::isloggedin();                 if (strlen($postbody) > 160 || strlen($postbody) < 1) {                     die('incorrect length!');                 }                  connect::query('insert dry_posts values (null, :postbody, now(), 0)', array(':postbody'=>$postbody));             }              else {                 //$postid = post::createimgpost($_post['postbody']);                 if (strlen($postbody) > 160) {                     die('incorrect length!');                 }                  connect::query('insert dry_posts values (null, :postbody, now(), 0)', array(':postbody'=>$postbody));                     $postid = connect::query('select id dry_posts order id desc limit 1');                     image::uploadimage('postimg', "update dry_posts set postimg=:postimg id=:postid", array(':postid'=>$postid));                 }             }              if (isset($_get['postid'])) {                 //post::likepost($_get['postid']);                 if (!connect::query('select post_id post_likes post_id=:postid', array(':postid'=>$_get['postid']))) {                     connect::query('update dry_posts set likes=likes+1 id=:postid', array(':postid'=>$_get['postid']));                     connect::query('insert post_likes values (null, :postid)', array(':postid'=>$_get['postid']));                 }                  else {                     connect::query('update dry_posts set likes=likes-1 id=:postid', array(':postid'=>$_get['postid']));                     connect::query('delete post_likes post_id=:postid', array(':postid'=>$_get['postid']));                 }             }              // $posts = post::displayposts();             $dbposts = connect::query('select * dry_posts order id desc');             $posts = "";              if(isset($_file['postimg'])){                  foreach($dbposts $p) {                     if (!connect::query('select post_id post_likes post_id=:postid', array(':postid'=>$p['id']))) {                         $posts .="<img src='".$p['postimg']."'>".htmlspecialchars($p['body'])."                         <form action='dry.php?postid=".$p['id']."' method='post'>                             <input type='submit' name='like' value='like'>                             <span>".$p['likes']." likes</span>                         </form>                         <hr /></br />                                 ";                     } else {                         $posts .="<img src='".$p['postimg']."'>".htmlspecialchars($p['body'])."                         <form action='dry.php?postid=".$p['id']."' method='post'>                             <input type='submit' name='unlike' value='unlike'>                             <span>".$p['likes']." likes</span>                         </form>                         <hr /></br />                                 ";                     }                 }             } ?>  <form action="try.php" method="post" class = "forum" enctype="multipart/form-data"> <textarea name="postbody" rows="4" cols="60" class = "text"></textarea>          <br />upload image:         <input type="file" name="postimg">         <input type="submit" name="post" value="post"> </form> 


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -