PHP – Send Data to PHP with HTML Form

Sending data to PHP from an HTML form is easy.


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


$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