rocksteadyvybes Posted March 5, 2009 Share Posted March 5, 2009 I am a complete newbie to PHP...please go easy on me I have a hw assignment for a web programming course but I've never used PHP before in my life. Basically, I need to make the following website work: http://rocksteadyvybes.nfshost.com/sign.html The user puts in their birthday, and I need the next site to literally only say "You are a _____(sign)". I have no idea how to code this however. Help. Please. Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/148032-coding-for-astrological-sign-site/ Share on other sites More sharing options...
phpdragon Posted March 5, 2009 Share Posted March 5, 2009 Setup a database table or flatfile with a list of star signs and the dates they fall between, then run your query based on what the date the user puts in your form, to make sure the data the user enters works tell the user what order to enter the date or setup your form to order it in the way you want it. Then echo the result formatted how you like back to the user. Quote Link to comment https://forums.phpfreaks.com/topic/148032-coding-for-astrological-sign-site/#findComment-777030 Share on other sites More sharing options...
PC Nerd Posted March 5, 2009 Share Posted March 5, 2009 alternatively - seeing as you appear to be only starting with php ... it might be easiest to look into setting an array with your field as the date, and the value as a date, and the value as the starsign ( of course you would have to parse the field as you loop through and check) but it'll save you the hastle of files and mysql if you are only just getting started with it. gdlk Quote Link to comment https://forums.phpfreaks.com/topic/148032-coding-for-astrological-sign-site/#findComment-777110 Share on other sites More sharing options...
rocksteadyvybes Posted March 5, 2009 Author Share Posted March 5, 2009 It's still not working....this is what I have as far as the php goes: ----- $date = "$_post[month], $_post[day]"; function getsign($date){ if(($month==1 && $day>20)||($month==2 && $day<20)){ return "Aquarius"; }else if(($month==02 && $day>18 )||($month==03 && $day<21)){ return "Pisces"; }else if(($month==03 && $day>20)||($month==04 && $day<21)){ return "Aries"; }else if(($month==04 && $day>20)||($month==05 && $day<22)){ return "Taurus"; }else if(($month==05 && $day>21)||($month==06 && $day<22)){ return "Gemini"; }else if(($month==6 && $day>21)||($month==07 && $day<24)){ return "Cancer"; }else if(($month==07 && $day>23)||($month==08 && $day<24)){ return "Leo"; }else if(($month==08 && $day>23)||($month==09 && $day<24)){ return "Virgo"; }else if(($month==09 && $day>23)||($month==10 && $day<24)){ return "Libra"; }else if(($month==10 && $day>23)||($month==11 && $day<23)){ return "Scorpio"; }else if(($month==11 && $day>22)||($month==12 && $day<23)){ return "Sagittarius"; }else if(($month==12 && $day>22)||($month==01 && $day<21)){ return "Capricorn"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/148032-coding-for-astrological-sign-site/#findComment-777512 Share on other sites More sharing options...
Mark Baker Posted March 5, 2009 Share Posted March 5, 2009 $starsign = getsign($_POST['day'],$_POST['month']); echo $starsign; function getsign($day,$month) { if(($month==1 && $day>20)||($month==2 && $day<20)){ return "Aquarius"; }else if(($month==02 && $day>18 )||($month==03 && $day<21)){ return "Pisces"; }else if(($month==03 && $day>20)||($month==04 && $day<21)){ return "Aries"; }else if(($month==04 && $day>20)||($month==05 && $day<22)){ return "Taurus"; }else if(($month==05 && $day>21)||($month==06 && $day<22)){ return "Gemini"; }else if(($month==6 && $day>21)||($month==07 && $day<24)){ return "Cancer"; }else if(($month==07 && $day>23)||($month==08 && $day<24)){ return "Leo"; }else if(($month==08 && $day>23)||($month==09 && $day<24)){ return "Virgo"; }else if(($month==09 && $day>23)||($month==10 && $day<24)){ return "Libra"; }else if(($month==10 && $day>23)||($month==11 && $day<23)){ return "Scorpio"; }else if(($month==11 && $day>22)||($month==12 && $day<23)){ return "Sagittarius"; }else if(($month==12 && $day>22)||($month==01 && $day<21)){ return "Capricorn"; } } Note $_POST rather than $_post (it is case sensitive) Note use of quotes around post vars: $_POST['month'] not $_POST'month] Note parameters passed to the function: $starsign = getsign($_POST['day'],$_POST['month']); Note parameters in function definition are actually used within the function code itself: function getsign($day,$month) Quote Link to comment https://forums.phpfreaks.com/topic/148032-coding-for-astrological-sign-site/#findComment-777521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.