PHP – Send Data to PHP with HTML Form

Sending data to PHP from an HTML form is easy.

//form.php

<form action="formscript.php" method="post">
 Your name: <input type="text" name="name" />
 <br>
 <select name="sizes">
    <option value="small">Small</option>
    <option value="medium">Medium</option>
    <option value="large">Large</option>
  </select>
 <br>
  <input type="checkbox" name="shift1" value="First Shift "> First Shift
 <br>
  <input type="checkbox" name="shift2" value="Second Shift"> Second Shift
 <br>
 <input type="submit" />
</form>
//formscript.php

<?php

$name = $_POST['name'];
$sizes = $_POST['sizes'];
$shift1 = $_POST['shift1'];
$shift2 = $_POST['shift2'];

print "Name: $name";
print "<br>";
print "T Shirt Size: $sizes";
print "<br>";
print "Shifts Available: ";
print $shift1;
print $shift2;

?>


Be the first to comment

Leave a Reply