Showing posts with label zodiac in php. Show all posts
Showing posts with label zodiac in php. Show all posts

Tuesday, September 30, 2014

Zodiac Sign Checker in PHP

This code is being given to us by my friend named Alfredo Soliva an IT student here in the Philippines in their programming class in PHP and MySQL programming. I am very happy that some programmers and students visiting my website and sharing their codes to help our fellow programmers and software engineers.

What that program will do is to ask the user to select form the combo box the month and day and then the program will check what zodiac sign belongs the user of our program. The code uses also some JavaScript for form validations and CSS for the design of the webpage. I hope the work of our friend Alfredo gives you an idea how to program in PHP.

Thank you very much.



Sample Output of Our Program

Program Listing

index.html

<html>
<head>
<title>Activity No. 1 Zodiac Sign</title>
<style type="text/css">
body {
background:#00FFFF;
}
#header {
width: 100%;
height: 120px;
background: #202020;
text-align: center;
font-size:xx-large;
}

#zodiac {
color: #999999;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: xx-large;
}
#zodiac:hover{
color:white;
}
#monthdate {
position:absolute;
left:40%;
top:100px;
}
#footer{
height: 40px;
border-top: 1px solid gray;
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>

<div id="header">
 <h1 class="style1" id="zodiac">ZODIAC SIGN</h1>
</div>

<div id = "monthdate">
<form method = POST action = result.php>
<!-- display dropdown list for month -->
<select name="month" id="month" onChange="adlaw(this.value)">
<option value = "0" disabled = "disabled" selected = " ">Month</option>
<option value = "1">January</option>
<option value = "2">February</option>
<option value = "3">March</option>
<option value = "4">April</option>
<option value = "5">May</option>
<option value = "6">June</option>
<option value = "7">July</option>
<option value = "8">August</option>
<option value = "9">September</option>
<option value = "10">October</option>
<option value = "11">November</option>
<option value = "12">December</option>
</select>
<!-- display dropdown list for day -->
<select name = "day" id = "day">
<option value = "day" disabled = "disabled" selected = " ">Day</option>
</select>
   <input type="submit" name="btnzodiac" value="Get My Zodiac">
</form>
</div>
<div id="footer">
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p><br />
  &copy; 2014 Midterm Project. Alfredo Rodriguez Soliva Jr./ All rights reserved.</p>
</div>

</body>

<script type="text/javascript">

var me;
var theLeap = document.getElementById("leap"); 
var theDay = document.getElementById("day"); 
var theMonth = document.getElementById("month");
var x; 

function adlaw(me){

if(me==4 || me==6 || me==9 || me ==11){
displayday(30);
}
else if(me==1 || me==3 || me==5 || me==7 || me==8 || me==10 || me==12){
displayday(31);
}
else if(me==2){
x = prompt ("enter your choice 'Y' for leap year 'N' if not");
if (x == 'y' || x == 'Y')
{
displayday(29);
}
else if (x == 'n' || x == 'N')
{
displayday(28);
}
else
{
alert ("please make a selection");
}
}
}

function displayday(num){ 
theDay.innerHTML=""; 
for(var ctr=1;ctr<=num;ctr++){ 
theDay.innerHTML = theDay.innerHTML+'<option value='+ctr+'>'+ctr+'</option>';
}
}

</script>

</html>

result.php

<html>
<style type="text/css">
body{
background-color:#99FFFF;
font-family:Geneva, Arial, Helvetica, sans-serif;
font-size:xx-large;
text-align:center;
}
#header {
width: 100%;
height: 120px;
background: #202020;
text-align: center;
font-size:xx-large;
color:#CCCCCC;
}

#header:hover {
color:#FFFFFF
}

#body:hover {
color:white;
}

#result:hover{
color:white;
font-size:50px;
}



</style>

<body>

<div id="header">
 <h1 class="style1" id="zodiac">Your ZODIAC SIGN</h1>
</div>
<div id="result">
<?php
$month = $_POST['month'];
$day = $_POST['day'];
if (($month == '3') && ($day>21) || ($month == '4') && ($day<19)){
print 'Aries.';
} elseif (($month == '2') && ($day>20) || ($month == '3') && ($day<20)){
print 'Pisces.';
} elseif (($month == '4') && ($day>20) || ($month == '5') && ($day<20)){
print 'Taurus.';
} elseif (($month == '5') && ($day>21) || ($month == '6') && ($day<20)){
print 'Gemini.';
} elseif (($month == '6') && ($day>21) || ($month == '7') && ($day<22)){
print 'Cancer.';
} elseif (($month == '7') && ($day>21) || ($month == '8') && ($day<22)){
print 'Leo.';
} elseif (($month == '8') && ($day>23) || ($month == '9') && ($day<22)){
print 'Virgo.';
} elseif (($month == '9') && ($day>23) || ($month == '10') && ($day<22)){
print 'Libra.';
} elseif (($month == '10') && ($day>23) || ($month == '11') && ($day<22)){
print 'Scorpio.';
} elseif (($month == '11') && ($day>23) || ($month == '12') && ($day<21)){
print 'Sagittarius.';
} elseif (($month == '12') && ($day>22) || ($month == '1') && ($day<21)){
print 'Capricorn.';
} elseif (($month == '1') && ($day>19) || ($month == '2') && ($day<19)){
print 'Aquarius.';
} else {  
print 'No information available';
}
?>
</div>
</body>

</html>

DOWNLOAD FILE HERE