Jump to content

Newbie in need of help


JamesUK91

Recommended Posts

Hi, I realise that this is a newbie question but I only started PHP at college last week.

I need to create a form where the user inputs a month of the year and the form outputs the number of days in that month.

My current code says that there are 31 days in every month..  :confused:

 

Here is what I have for the form, this part is working fine

<form name="months" method="post" action="Task2Algorithm1.php">

Enter Month <input name="month" ><br>

    <button type="submit" style="float:left">Submit</button>

</form>

 

And here is the code for the form, dreamweaver is saying there are no syntax errors but it still isn't working because it says there are 31 days in each month, so I have no idea.

<?php

$month=$_POST['month'];

 

if ($month == "January" OR "March" OR "May" OR "July" OR "August" OR "October" OR "December")

{

echo "The number of days in this month is 31";

}

 

elseif ($month == "April" OR "June" OR "September" OR "November")

{

echo "The number of days in this month is 30";

}

 

elseif ($month == "February")

{

echo "The number of days in this month is 28";

}

?>

 

Any suggestions would be GREATLYYY appreciated :)

 

Link to comment
https://forums.phpfreaks.com/topic/245083-newbie-in-need-of-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.