php - how to properly use the like system twitter style button -


i created system user can post of user.. data inserted db. problem dont have idea on how stay button if user post.. cause happen when user post , refresh page button refresh/back unlike

this looks default icon of button gray. when user hover button runs animation , when user hit should turn red. since when user hit button run reload page button returns gray.. think im missing dont have idea how it.....enter image description here

css

.coracao{   background: url("https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png");  height: 50px;  width: 50px;  background-size: 2900%;  background-position: left center;     top: -30px;   left:  0px;   position:absolute;  } .coracao.ativo{   background: url("https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png");  height: 50px;  width: 50px;  background-size: 2900%;  background-position: right center;     top: -30px;   left:  0px;   position:absolute;   animation: none 0s !important;     -moz-animation: none 0s !important;  } .btn:hover .coracao{ animation: animationframes 1.4s steps(28) infinite; }  @keyframes animationframes{    100%{ background-position: -2800px ;    } } 

i think need make condition here dont have idea on do... button

<div class="btn like">      <div class="boxcoracao">         <span class="coracao" name="like"><br>&emsp;&emsp;&emsp;love</span>     </div> </div>&emsp;&emsp;&emsp; 

this insert data of user , post id

<script>  $(".like").click(function(){    if ($('.boxcoracao .coracao',this).toggleclass("ativo")){       togglepost("like"); // run function    } else {    // update text show next click     togglepost("dislike"); // run function   }   function togglepost(action){    $.ajax({         type: "post",         url: "",         data: "",         success: function(data){           window.location.reload();         },         error: function(e){          alert("please try again...");         }       });  }  });  </script> 

when query of posts, need pull 'like' state of post doing join on active user's likes, , setting content of button based on flag.

i'm example, there no php process page when loaded. asking functionality possible using server side script processes output of page based on contents of database.

research php web applications. not achievable pure js, html, , css.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -