-3

I am working on a part were user post their status.! And that the post will be seen by other members in community, and their "i want to hide delete post option form other members of group/community" or simply delete post option only available to user who has posted it..! By taking below advice i have edited my code accordingly but its giving me a error Parse error: syntax error, unexpected 'if' (T_IF)

code.php

echo '<div class="col-lg-12">

                <div class="social-feed-box">' .if($_SESSION['via'] == $row['via']){.               

                    '<div class="pull-right social-action dropdown">
                        <button data-toggle="dropdown" class="dropdown-toggle btn-white">
                            <i class="fa fa-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu m-t-xs">
                            <li><a href="post_delete.php">Delete</a></li>
                        </ul>
                </div>' .}. '<div>..... 
user
  • 3
  • 6
  • Do a SQL query to the DB, check if the poster's ID matches with the session id (_if you have this_) and then put the delete link/button in the `elseif` statement. – node_modules Apr 21 '16 at 06:22
  • 1
    You can easily do that by a check `if($logged_in_user == $posted_user_id){//display delete button html code}` ? – Niklesh Raut Apr 21 '16 at 06:24
  • as @Rishi mentioned , check if the logged user = post user id , but you have to add more security layer in the delete page/action – hassan Apr 21 '16 at 06:26
  • sir i have done some thing by taking your advice and updated my code..but its giving out error as Parse error: syntax error, unexpected 'if' (T_IF) plz help me out.! – user Apr 21 '16 at 07:11

1 Answers1

0

try this

<?php
$_SESSION['via'] =1;
$row['via'] =1;

 
  
echo '<div class="col-lg-12">

                <div class="social-feed-box">';

    if($_SESSION['via'] == $row['via']) { 
     
    echo '<div class="pull-right social-action dropdown">
                        <button data-toggle="dropdown" class="dropdown-toggle btn-white">
                            <i class="fa fa-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu m-t-xs">
                            <li><a href="post_delete.php">Delete</a></li>
                        </ul>';
     
    }
          echo  '</div>';


 
?>
JYoThI
  • 11,977
  • 1
  • 11
  • 26