Not a php guru
here.
I have one form
and when I hit the submit
, it runs the function()
:
<form id="saveId" action="" method="POST" class="" autocomplete="off">
<input type="hidden" name="save_post_value" value="<?php echo $userPosts; ?>">
<button type="submit" class="save_post btn btn-danger">Save to box</button>
</form>
<?php
if($_SERVER['REQUEST_METHOD']=="POST") {
update_user_meta( $user_id, 'save_post', $userPosts );
}
?>
That's fine with one form, but what if we have two forms and functions?
<form id="saveId" action="" method="POST" class="" autocomplete="off">
<input type="hidden" name="save_post_value" value="<?php echo $userPosts; ?>">
<button type="submit" class="save_post btn btn-danger">Save to box</button>
</form>
<form id="favorite" action="" method="POST" class="" autocomplete="off">
<input type="hidden" name="save_fav" value="<?php echo $userfavs; ?>">
<button type="submit" class="save_fav btn btn-danger">Add to favs</button>
</form>
Can't do obviously:
<?php
if($_SERVER['REQUEST_METHOD']=="POST") {
update_user_meta( $user_id, 'save_post', $_POST['save_post_value'] );
}
if($_SERVER['REQUEST_METHOD']=="POST") {
update_user_meta( $user_id, 'save_fav', $_POST['save_fav'] );
}
?>