Jump to content

coding for Astrological Sign site


rocksteadyvybes

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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";

    }

}

   

    ?>

Link to comment
Share on other sites

$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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.