The following HTML form passes a value to sleepy-time.php with the name sleepHours. Which PHP statement would correctly receive this value and assign it to a PHP variable named $sleepHours?

How many hours do you sleep each night:

Respuesta :

Answer:

$sleepHours = $_POST['sleepHours'];

Explanation:

The following HTML form passes a value to sleepyTime.php with the name sleepHours. Which PHP statement would correctly receive this value and assign it to a PHP variable named $sleepHours?

<form action = "sleepyTime.php" method = "post">

<p>How many hours do you sleep each night:

<input type = "text" size = "20" name = "sleepHours">

</p>

<input type = "submit" value = "Can I sleep now?">

</form>

In PHP, the $_POST statement is a superglobal variable that is used to collect values from HTML forms.  It is this $sleepHours = $_POST['sleepHours']; statement that will correctly receive the value and assign it to a PHP variable named $sleepHours.

ACCESS MORE