Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6807133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:47:41+00:00 2026-05-26T19:47:41+00:00

I’m currently trying to improve my PHP skills and I have a sample below

  • 0

I’m currently trying to improve my PHP skills and I have a sample below I am trying to work with. The first webpage (not shown here) is a form that contains one field, Name:, which then gets submitted to another page (shown below), where the form is processed.

For some reason the PHP code appears to be validated, but it is not outputting anything when I run a test. The input name for the field on the first page is “name”, then the information is sent to the PHP file shown below. Then the file is supposed to compare the time of day and then output a message based on the date information gathered. It’s not working though.

(Also, I know that the bgcolor attribute is deprecated, and I found the example online)

Any help would be appreciated. Thanks, Rob

<!DOCTYPE html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Databases and Webprogramming: Assignment 4.1</title>
</head>
<body bgcolor="#f9f9f9">
<?php

//import form information 
$name = $_POST['name'];

$current = date('H');

if ($current < 12)
echo "Good morning, $name!<br />";

elseif ($current==12 && $current<=18) 
echo "Good afternoon, $name!<br />";

elseif ($current >= "19" && $current <= "24") 
echo "Good evening, $name!<br />";
?>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:47:41+00:00Added an answer on May 26, 2026 at 7:47 pm

    As you say you dont see any output the error is most likely located around $current. Otherwise you should at least see the static part of the output strings. I only see one mistake in the second condition. $current==12 should be $current>=12. Depending on your timezone this can fix the issue because the code as is cant output anything between 13 and 18 o’clock.

    If this does not fix it try using curved parantheses to avoid overseeing errors where you misplaced semicolons. Maybe you want to print the value of $current outside of the if conditions and debug the code a bit.

    Edit: Oh and you should not use numbers as string (e.g. "19"). If you want to be type safe you can write $current = (int) date('H');

    Edit #2: I just recognized those dozens of comments and found the link. When I type in test and submit the form I get Good evening, test!. Note that the script is using the timezone of the server. I should actually see a friendly “good morning” as it is 2am in the morning over here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.