3v4l.org

run code in 300+ PHP versions simultaneously
<html> <head> <title>Process the HTML form data with the POST method</title> </head> <body> <form name="myform" action="process.php" method="POST"> <input type="hidden" name="check_submit" value="1" /> Name: <input type="text" name="Name" /><br /> Password: <input type="password" name="Password" maxlength="10" /><br /> Select something from the list: <select name="Seasons"> <option value="Spring" selected="selected">Spring</option> <option value="Summer">Summer</option> <option value="Autumn">Autumn</option> <option value="Winter">Winter</option> </select><br /><br /> Choose one: <input type="radio" name="Country" value="USA" /> USA <input type="radio" name="Country" value="Canada" /> Canada <input type="radio" name="Country" value="Other" /> Other <br /> Choose the colors: <input type="checkbox" name="Colors[]" value="green" checked="checked" /> Green <input type="checkbox" name="Colors[]" value="yellow" /> Yellow <input type="checkbox" name="Colors[]" value="red" /> Red <input type="checkbox" name="Colors[]" value="gray" /> Gray <br /><br /> Comments:<br /> <textarea name="Comments" rows="10" cols="60">Enter your comments here</textarea><br /> <input type="submit" /> </form> <?php //Check whether the form has been submitted if (array_key_exists('check_submit', $_POST)) { //Converts the new line characters (\n) in the text area into HTML line breaks (the <br /> tag) $_POST['Comments'] = nl2br($_POST['Comments']); //Check whether a $_GET['Languages'] is set if ( isset($_POST['Colors']) ) { $_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array into a single string } //Let's now print out the received values in the browser echo "Your name: {$_POST['Name']}<br />"; echo "Your password: {$_POST['Password']}<br />"; echo "Your favourite season: {$_POST['Seasons']}<br /><br />"; echo "Your comments:<br />{$_POST['Comments']}<br /><br />"; echo "You are from: {$_POST['Country']}<br />"; echo "Colors you chose: {$_POST['Colors']}<br />"; } else { echo "You can't see this page without submitting the form."; } ?> </body> </head> </html>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<html> <head> <title>Process the HTML form data with the POST method</title> </head> <body> <form name="myform" action="process.php" method="POST"> <input type="hidden" name="check_submit" value="1" /> Name: <input type="text" name="Name" /><br /> Password: <input type="password" name="Password" maxlength="10" /><br /> Select something from the list: <select name="Seasons"> <option value="Spring" selected="selected">Spring</option> <option value="Summer">Summer</option> <option value="Autumn">Autumn</option> <option value="Winter">Winter</option> </select><br /><br /> Choose one: <input type="radio" name="Country" value="USA" /> USA <input type="radio" name="Country" value="Canada" /> Canada <input type="radio" name="Country" value="Other" /> Other <br /> Choose the colors: <input type="checkbox" name="Colors[]" value="green" checked="checked" /> Green <input type="checkbox" name="Colors[]" value="yellow" /> Yellow <input type="checkbox" name="Colors[]" value="red" /> Red <input type="checkbox" name="Colors[]" value="gray" /> Gray <br /><br /> Comments:<br /> <textarea name="Comments" rows="10" cols="60">Enter your comments here</textarea><br /> <input type="submit" /> </form> You can't see this page without submitting the form.</body> </head> </html>

preferences:
281.56 ms | 408 KiB | 328 Q