Reputation: 37
I have written a simple PHP code:
<?php
if (isset($_GET['day']) && isset($_GET['date']) && isset($GET['year'])) {
$day = $_GET['day'];
$date = $_GET['date'];
$year = $_GET['year'];
if (!empty($day) && !empty($date) && !empty($year)) {
echo 'It is '.$day.' '.$date.' '.$year;
} else {
echo 'Fill in all fields.';
}
}
?>
<form action="index.php" method="GET">
Day:<br><input type="text" name="day"><br>
Date:<br><input type="text" name="date"><br>
Year:<br><input type="text" name="year"><br><br>
<input type="submit" value="Submit">
</form>
To me, everything looks OK. No errors after running. But, neither the output. Non of the echos shows up. Form is there and I enter data, but when I click "Submit", it just stays the same. URL of the page changes and I can see entered data there, but no echos on the page. I have checked the code for spelling errors, and I haven't found any. Thanks in advance.
Upvotes: 0
Views: 10436
Reputation: 95121
It is $_GET
not $GET
You need to add an underscore:
$GET['year']
to:
$_GET['year']
Upvotes: 4
Reputation: 6653
You forgot an underscore at this:
if (isset($_GET['day']) && isset($_GET['date']) && isset($GET['year'])) {
at the last get
if (isset($_GET['day']) && isset($_GET['date']) && isset($_GET['year'])) {
Upvotes: 8