mysql - PHP save a log db entry on a successful form post -


in code below, i'm looping through set of text area boxes ('note[]') on user form insert multiple database records based on how many text area boxes have datafill.

i'm trying figure out how create logs table entry each successful db save in post action of user form. i'm couple of weeks learning php , first time i've tried embed query inside post action query.

can see what's wrong existing sample code or explain i'm doing wrong? right "log write success" every record save if db write worked, logs table remains empty. can't figure out why inserts logs table aren't working.

for code below, if had 6 'note[]' text boxes datafill, see "log write success" echo 6 times. logs db table remain empty.

thank you!

<?php $added_notes = 0; foreach ($_post['note'] $value) {     $cleaned_value = strip_tags($value);     $result = mysqli_query($con, "insert weekly_notes.notes(user_id,log_date,note) values('$user_id','$log_date','$cleaned_value')");      if($result)     {         #-------------------- create log entry ----------------------------         # !!!! not working - no records saved          $log_result = mysqli_query($con, "insert weekly_notes.note_logs(user_id) values('1')");         if($result)         {             echo "log write success<br/>";         } else {             echo "log write error<br/>";         }         #----------------------------------------------------------------------------          $added_notes++;         echo "-----------------------<b>new note created</b>-----------------------<br/>";         echo "<b>note owner:</b> "  . $user_id . "</b><br/>";                                    echo "<b>note date:</b> $note_date " . "<br/>";         echo "<b>note:</b> " . $cleaned_value . "<br/>";         echo "---------------------------------------------------------------------------------------------------------------------<br/>";         echo "<br/>";     } else {         echo "error: ";     }                        } ?> 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -