php get value input code example

Example 1: get text field value in php

<form method="post">
  <input type="text" name="deleteinput" class="button"/>
  <input type="submit" name="deletebtn" class="button" value="Delete single user data"/>
</form>
  // php 
<?php 
    $name = $_GET['deletebtn'];
    echo $name;
?>

Example 2: php post variables to another page with submit button php

<html>
<form id="form" action="webAddressYouWantToRedirectTo.php" method="POST">
<input type="hidden" name="expectedPOSTVarNameOnTheOtherPage" value="<?php echo $varYouMadePreviouslyInProcessing ?>">
</form>
<script>
document.getElementById("form").submit();
</script>
</html>

Example 3: how to get input value in php variable

$info = array('Doina', 'brown', 'long');

// Listing all the variables
list($she, $color, $hear) = $info;
echo "$she has $color eyes color and $hear black hair.\n";