html - Sending empty values to text file from php -


im trying send "rating" value php file text file. when im checking console log says value has been sent. though when im checking text file nothing has been added. text file said updated.

anyway, here's code:

<form name="star" id="star">         <div id="rating-area" class="shadow">         <img src="star-icon.png" id="thumb1" value="1" onclick="poststar()"/>     <img src="star-icon.png" id="thumb2" value="2" onclick="poststar()"/>     <img src="star-icon.png" id="thumb3" value="3" onclick="poststar()"/>     <img src="star-icon.png" id="thumb4" value="4" onclick="poststar()"/>     <img src="star-icon.png" id="thumb5" value="5" onclick="poststar()"/>      </div>   </form> <script> function poststar() {     var starinput = $("#star").val();         $.post("post.php",      {         star:starinput     },     function(data, status){         console.log("data: " + data + " - status: " + status);     }     ); }  </script> 

and post.php file:

<?php echo "hittar php-fil";   if(isset($_post['star'])){      $star = $_post['star'];        file_put_contents('textfile.txt', $star . "\n", file_append);  echo "lgger in txt-fil";   } ?> 

i can't tell problems occurs.

<form name="star" id="star">         <div id="rating-area" class="shadow">         <img src="star-icon.png" id="thumb1" data-value="1" />     <img src="star-icon.png" id="thumb2" data-value="2" />     <img src="star-icon.png" id="thumb3" data-value="3" />     <img src="star-icon.png" id="thumb4" data-value="4" />     <img src="star-icon.png" id="thumb5" data-value="5" />      </div>   </form> <script>      // jquery(document).on('click','div#rating-area img',function(e){    jquery('div#rating-area img').click(function(e){         var val = jquery(this).data('value') ;         console.log(val) ;         jquery.post('post.php',{ star : val },function(data,status){             console.log('data:'+data+'/status'+status) ;         }) ;     }) ;  </script> 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -