html button send post request code example

Example 1: using post from any button

$('.btn-logout').on('click', function() {
		$('<form action="<?=$url_local?>member/logout" method="post"> <input name="token" value="<?= $obj_user ? $obj_user['token'] : '' ?>"/> </form>').appendTo('body').submit();
	});

Example 2: html button send post request

<form method='POST' action='myFile.php'>
  <input name='myInput'>
  <button type='submit'>Submit</button> 
  <!--Sends input value to the page set as 'action' parameter. 
	For example a php file.-->
</form>

Tags:

Html Example