Jump to content

[SOLVED] Determining birth year


twilitegxa

Recommended Posts

What I want to do is eliminate the need for the viewer to type in the birth year and to have a math statement that calculates it based on the age they put in and takes into account the month and day as well to determine what year they were born, and then send that number to my database. Here is my code for my form: (I have a field in my table in my databse named birthdateyear, that I want to store the year of birth into) How do I do that?

 

<?php

session_start();

?>

<?php

//Access Tracking Snippet

//set up static variables
$page_title = "creationform.php";
$user_agent = getenv("HTTP_USER_AGENT");
$date_accessed = date("Y-m-d");

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//create and issue query
$sql = "insert into access_tracker values
('', '$page_title', '$user_agent', '$date_accessed')";
mysql_query($sql,$conn);
?>

<html>
<head>
<title>Sailor Moon RPG - Character Creation Form</title>
<!-- Source File -->
<link rel="stylesheet" type="text/css" href="ddlevelsfiles/ddlevelsmenu-base.css" />

<link rel="stylesheet" type="text/css" href="ddlevelsfiles/ddlevelsmenu-sidebar.css" />

<script type="text/javascript" src="ddlevelsfiles/ddlevelsmenu.js">
</script>
<link rel="stylesheet" type="text/css" href="simpletree2.css" />
<!--[if IE]>
<style>
#main
{
padding: 20px 0 20px 0;
}

</style>
<![endif]-->
</head>
<body>
<div id="head"><img src="logo.jpg" alt="Sailor Moon RPG Logo" width="314" height="75" /><br />

<address><a href="home.php">Home</a> | <a href="register.php">Register</a> | <a href="help.php">Help</a>
</address></div>
<table align="right">
<tr>
<td><?php
if ($_SESSION['loggedIn'] == 1) {
?>
<p>Welcome, <?php echo $_SESSION['userName'] ?> (<a href="logout.php" title="Log Out">Log Out</a>)</p>
<?php
} else {
?>
<p>Please <a href="login.php">log in</a></p>
<?php } ?>
</td>
</tr>
</table><br />
<div id="ddsidemenubar" class="markermenu">
<ul>
<li><a href="home.php" title="Home Page">Home</a></li>
<li><a href="#" title="Getting Started" rel="ddsubmenuside1">Getting Started</a></li>
<li><a href="creationform.php" title="Create Character" class="select">Create Character</a></li>
<li><a href="#" rel="ddsubmenuside2" title="Members">Members</a></li>
<li><a href="newsandevents.php" title="News And Events">News And Events</a></li>
<li><a href="glossary.php" title="Glossary">Glossary</a></li>
<li><a href="topiclist2.php" title="Battle Board">Battle Board</a></li>
<li><a href="chat/chatframe.php" title="Battle Chat Lounge">Battle Chat Lounge</a></li>
<li><a href="about.php" title="About Us">About Us</a></li>
<li><a href="news.php" title="Newsletters">Newsletters</a></li>
<li><a href="invite.php" title="Invite Friends">Invite Friends</a></li>
<li><a href="topiclist.php" title="Discussion Board Forum">Discussion Board</a></li>
<li><a href="faq.php" title="Frequently Asked Questions">FAQ</a></li>
<li><a href="contact.php" title="Contact Us">Contact Us</a></li>
</ul>
</div>

<script type="text/javascript">
ddlevelsmenu.setup("ddsidemenubar", "sidebar") //ddlevelsmenu.setup("mainmenuid", "topbar|sidebar")
</script>

<!--HTML for the Drop Down Menus associated with Side Menu Bar-->
<!--They should be inserted OUTSIDE any element other than the BODY tag itself-->
<!--A good location would be the end of the page (right above "</BODY>")-->


<!--Side Drop Down Menu 1 HTML-->

<ul id="ddsubmenuside1" class="ddsubmenustyle blackwhite">
<li><a href="#" title="Chapter 1: Introduction" rel="ddsubmenuside3">Chapter 1: Introduction</a>

<ul class="smaller2"><li><a href="genre.php" title="The Magical Girl Genre">The Magical Girl Genre</a></li><li><a href="sailormoon.php" title="Bishojo Senshi Sailormoon"><em>Bishojo Senshi Sailormoon</em></a><li><a href="seriesbackground.php" title="Sailor Moon Series Background">Sailor Moon Series Background</a><ul class="smaller3"><li><a href="summary1.php" title="Season One Summary (Episodes #1 - #40)">Season One Summary</a></li><li><a href="summary2.php" title="Season Two Summary (Episodes #41 - #82)">Season Two Summary</a></li></ul></li><li><a href="roleplaying.php" title="What Is Role-Playing?">What Is Role-Playing?</a></li><li><a href="example.php" title="An Example Of Play">An Example Of Play</a></li><li><a href="size.php" title="Character Size Relationship">Character Size Relationship</a></li></ul></li>
<li><a href="creation.php" title="Chapter 2: Character Creation">Chapter 2: Character Creation</a>
<ul class="smaller4"><li><a href="flowchart.php" title="Character Creation Flowchart">Character Creation Flowchart</a></li><li><a href="gmdiscussion.php" title="GM Discussion">Step 1: GM Discussion</a></li><li><a href="outline.php" title="Character Outline">Step 2: Character Outline</a></li><li><a href="stats.php" title="Assign Stats">Step 3: Assign Stats</a></li><li><a href="attributes1.php" title="Character Attributes">Step 4: Character Attributes</a><ul><li><a href="attributes2.php" title="Scout/Knight Sub-Attributes">Scout/Knight Sub-Attributes</a></li><li><a href="attributes3.php" title="Negaverse/Dark Sub-Attributes">Negaverse/Dark Sub-Attributes</a></li><li><a href="attributes4.php" title="Neutral Attributes">Neutral Attributes</a></li></ul></li><li><a href="defects.php" title="Character Defects">Step 5: Character Defects</a></li><li><a href="derived.php" title="Derived Values">Step 6: Derived Values</a><ul class="smaller5"><li><a href="derived.php#combat" title="Combat Value">Combat Value</a></li><li><a href="derived.php#health" title="Health Points">Health Points</a></li><li><a href="derived.php#energy" title="Energy Points">Energy Points</a></li></ul></li><li><a href="background.php" title="Background Points">Step 7: Background Points</a></li></ul></li>
<li><a href="#" title="Chapter 3: Game Mechanics">Chapter 3: Game Mechanics</a>
<ul class="smaller6"><li><a href="introduction.php" title="Introduction">Introduction</a></li>
<li><a title="Combat Flowchart">Combat Flowchart</a></li>
<li><a href="dice.php" title="Dice, Stat Checks, & Combat Rolls">Dice, Stat Checks, & Combat Rolls</a><ul class="smaller7"><li><a href="dice.php#stat" title="Stat Checks">Stat Checks</a></li><li><a href="dice.php#combat" title="Combat Dice Rolls">Combat Dice Rolls</a></li></ul></li>
<li><a href="action.php" title="Taking Action">Taking Action</a></li>
<li><a href="combat.php" title="Combat">Combat</a><ul class="smaller8"><li><a href="combat.php#initiative" title="Initiative">Initiative</a></li><li><a href="combat.php#attack" title="Attack">Attack</a></li><li><a href="combat.php#noncombat" title="Non-Combat Actions">Non-Combat Actions</a></li><li><a href="combat.php#defend" title="Defend">Defend</a></li><li><a href="combat.php#damage" title="Deliver Damage">Deliver Damage</a></li></ul></li>
<li><a href="weapons.php" title="Weapons And Armor">Weapons And Armor</a></li>
<li><a href="recovering.php" title="Recovering Lost Points">Recovering Lost Points</a>
<ul class="smaller9"><li><a href="recovering.php#health" title="Health Points">Health Points</a></li>
<li><a href="recovering.php#energy" title="Energy Points">Energy Points</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="universe.php" title="Role-Playing In A Sailor Moon Universe">Chapter 4: RPing In A SM Universe</a>
<ul class="smaller10"><li><a href="japan.php" title="Japan And Tokyo">Japan And Tokyo</a></li>
<li><a href="#" title="Maps Of Japan And Tokyo">Maps Of Japan and Tokyo</a></li>
<li><a href="places.php" title="Places In Sailor Moon">Places In Sailor Moon</a></li>
<li><a href="timeline.php" title="Sailor Moon Timeline">Sailor Moon Timeline</a></li>
<li><a href="kingdom.php" title="The Moon Kingdom">The Moon Kingdom</a>
<ul class="smaller11"><li><a href="kingdom.php#light" title="The Kingdom Of Light">The Kingdom Of Light</a></li>
<li><a href="kingdom.php#members" title="Members Of The Royal Court">Members Of The Royal Court</a></li>
<li><a href="kingdom.php#planetary" title="The Planetary Kingdoms">The Planetary Kingdoms</a></li>
</ul>
</li>
<li><a href="negaverse.php" title="The Negaverse">The Negaverse</a>
<ul class="smaller12"><li><a href="negaverse.php#known" title="What Is Known">What Is Known</a></li>
<li><a href="negaverse.php#unknown" title="Speculation On What Is Unknown">Speculation On Unknown</a></li>
</ul>
</li>
<li><a href="makaiju.php" title="Planet Of Makaiju">Planet Of Makaiju</a>
<ul class="smaller13"><li><a href="makaiju.php#campaign" title="Campaign And Setting Questions">Campaign & Setting Questions</a></li></ul>
</li>
<li><a  href="crystal.php" title="Crystal Tokyo">Crystal Tokyo</a>
<ul><li><a href="crystal.php#campaign" title="A Crystal Tokyo Campaign">A Crystal Tokyo Campaign</a></li></ul>
</li>
<li><a href="nemesis.php" title="Nemesis, The Dark Moon">Nemesis, The Dark Moon</a></li>
<li><a href="life.php" title="School Life In Japan">School Life In Japan</a></li>
<li><a href="advice.php" title="Advice For The Player">Advice For The Player</a></li>
</ul>
</li>
</ul>

<!--Side Drop Down Menu 2 HTML-->

<ul id="ddsubmenuside2" class="ddsubmenustyle blackwhite smaller1">
<li><a href="heroes.php" title="Heroes">Heroes</a></li>
<li><a href="villains.php" title="Villains">Villains</a></li>
</ul>
<div id="main">
<form action="insert.php" method="post">
<h1>Character Creation</h1>
<table border="0" width="100%">
  <tr>
    <td>Identity:</td>
    <td><input type="text" name="identity" size="30" maxlength="100"></td>
  </tr>
  <tr>
    <td>Character Name:</td>
    <td><input type="text" name="charactername" size="30" maxlength="100"></td>
  </tr>

  <tr>
    <td>Element Of Influence:</td>
    <td>
    <SELECT NAME="elementofinfluence" SIZE="1">
    <OPTION value="Purity And The Soul">Purity/Soul</OPTION>
    <OPTION value="Water">Water</OPTION>
    <OPTION value="Fire">Fire</OPTION>
    <OPTION value="Wood/Lightning">Wood/Lightning</OPTION>
    <OPTION value="Love/Metal">Love/Metal</OPTION>
    <OPTION value="Earth">Earth</OPTION>
    <OPTION value="Time">Time</OPTION>
    <OPTION value="Death And Healing">Death/Healing</OPTION>
    <OPTION value="Light">Light</OPTION>
    </SELECT></td>
  </tr>
<tr>
    <td>Age:</td>
    <td><input type="text" name="age" size="2" maxlength="2"></td>
  </tr>
    <tr>
    <td>Date Of Birth:</td>
    <td><SELECT NAME="birthdatemonth" SIZE="1">
    <OPTION value="January">January</OPTION>
    <OPTION value="February">February</OPTION>
    <OPTION value="March">March</OPTION>
    <OPTION value="April">April</OPTION>
    <OPTION value="May">May</OPTION>
    <OPTION value="June">June</OPTION>
    <OPTION value="July">July</OPTION>
    <OPTION value="August">August</OPTION>
    <OPTION value="September">September</OPTION>
    <OPTION value="October">October</OPTION>
    <OPTION value="November">November</OPTION>
    <OPTION value="December">December</OPTION>
    </SELECT>
    <SELECT NAME="birthdateday" SIZE="1">
    <OPTION value="01">1</OPTION>
    <OPTION value="02">2</OPTION>
    <OPTION value="03">3</OPTION>
    <OPTION value="04">4</OPTION>
    <OPTION value="05">5</OPTION>
    <OPTION value="06">6</OPTION>
    <OPTION value="07">7</OPTION>
    <OPTION value="08">8</OPTION>
    <OPTION value="09">9</OPTION>
    <OPTION value="10">10</OPTION>
    <OPTION value="11">11</OPTION>
    <OPTION value="12">12</OPTION>
    <OPTION value="13">13</OPTION>
    <OPTION value="14">14</OPTION>
    <OPTION value="15">15</OPTION>
    <OPTION value="16">16</OPTION>
    <OPTION value="17">17</OPTION>
    <OPTION value="18">18</OPTION>
    <OPTION value="19">19</OPTION>
    <OPTION value="20">20</OPTION>
    <OPTION value="21">21</OPTION>
    <OPTION value="22">22</OPTION>
    <OPTION value="23">23</OPTION>
    <OPTION value="24">24</OPTION>
    <OPTION value="25">25</OPTION>
    <OPTION value="26">26</OPTION>
    <OPTION value="27">27</OPTION>
    <OPTION value="28">28</OPTION>
    <OPTION value="29">29</OPTION>
    <OPTION value="30">30</OPTION>
    <OPTION value="31">31</OPTION>
    </SELECT> <input type="text" name="birthdateyear" size="4" maxlength="4"></td>
  </tr>
  <tr>
    <td>Height:</td>
    <td><input type="text" name="heightfeet" size="2" maxlength="2"> feet <input type="text" name="heightinches" size="2" maxlength="2"> inches</td>
  </tr>
  <tr>
    <td>Blood Type:</td>
    <td><input type="text" name="bloodtype" size="4" maxlength="4"> <a href="bloodtype.php" title="Help!"><img src="question.gif" /></a>    </td>
  </tr>
  <tr>
    <td>Hobbies:</td>
    <td><input type="text" name="hobbies" size="30" maxlength="100">
    </td>
  </tr>
  <tr>
    <td>Favorite Color:</td>
    <td><input type="text" name="favoritecolor" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td>Favorite Gemstone:</td>
    <td><input type="text" name="favoritegemstone" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td>Favorite Food:</td>
    <td><input type="text" name="favoritefood" size="10" maxlength="30">
    </td>
  </tr>
  <tr>
    <td>Least Favorite Food:</td>
    <td><input type="text" name="leastfavoritefood" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td>Favorite School Subject:</td>
    <td><input type="text" name="favoriteschoolsubject" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td>Least Favorite School Subject:</td>
    <td><input type="text" name="leastfavoriteschoolsubject" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td>Strengths:</td>
    <td><input type="text" name="strengths" size="30" maxlength="100">
    </td>
  </tr>
  <tr>
    <td>Weaknesses:</td>
    <td><input type="text" name="weaknesses" size="30" maxlength="100">
    </td>
  </tr>
  <tr>
    <td>Goal:</td>
    <td><input type="text" name="goal" size="30" maxlength="100">
    </td>
  </tr>
  <tr>
    <td>Character Biography:</td>
    <td><textarea name="biography" rows=7 
cols=46></textarea>
    </td>
  </tr>
</table>
<p style="text-align: center"><input type="submit" value="Create Character" />
<input type="reset" value="Reset" /></p>

</form>
</div>
<address>
<a href="guestbook.php">Sign Guestbook</a> | <a href="guestbookdisplay.php">View Guestbook</a> | <a href="help.php">Help</a> | <a href="contactus.php">Contact Us</a>
</address>
</html>

Link to comment
Share on other sites

So, for your example, Barand, you said:

 

age = x

 

yob = currentyear - age

 

if (monthnow.daynow < mob.dob) yob--

 

So I need to name a variable and set it to the age, and then set a variable for current year - the variable age, and then I'm a little confused on the if statement. Am I right so far? Also, how would I alter the code if I have a set year I want to use? Like a year in the past? I have the form obtaining the age from the field named 'age' on the form. How would I write the variable statement to save the information to the variable from what the person types into the age field? I'm still learning how to make variables in this way.

Link to comment
Share on other sites

First step is to make your month option values numeric. You can't do calculations with "September"

 

<?php
function yearOfBirth ($day, $month, $age)
{
    $yob = date('Y') - $age;
    
    if (date('md') < sprintf('%02d%02d', $month, $day)) $yob--;
    
    return $yob;
}

$year =  yearOfBirth($_POST['birthdateday'], $_POST['birthdatemonth'], $_POST['age']);

echo $year;
?>

 

echo yearOfBirth (16, 12, 62);          // 1945

echo yearOfBirth (22, 1, 59);          // 1949

Link to comment
Share on other sites

This is my insert.php page:

 

<?php

session_start();

?>

<?php

//Access Tracking Snippet

//set up static variables
$page_title = "insert.php";
$user_agent = getenv("HTTP_USER_AGENT");
$date_accessed = date("Y-m-d");

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//create and issue query
$sql = "insert into access_tracker values
('', '$page_title', '$user_agent', '$date_accessed')";
mysql_query($sql,$conn);
?>

<html>
<head>
<title>Sailor Moon RPG - Character Creation - Successful</title>
<meta HTTP-EQUIV="REFRESH" content="1; url=http://localhost/files/home.php">
<!-- Source File -->
<link rel="stylesheet" type="text/css" href="ddlevelsfiles/ddlevelsmenu-base.css" />

<link rel="stylesheet" type="text/css" href="ddlevelsfiles/ddlevelsmenu-sidebar.css" />

<script type="text/javascript" src="ddlevelsfiles/ddlevelsmenu.js">
</script>
<link rel="stylesheet" type="text/css" href="simpletree2.css" />
<!--[if IE]>
<style>
#main
{
padding: 20px 0 20px 0;
}

</style>
<![endif]-->
</head>
<body>
<div id="head"><img src="logo.jpg" alt="Sailor Moon RPG Logo" width="314" height="75" /><br />

<address><a href="home.php">Home</a> | <a href="register.php">Register</a> | <a href="help.php">Help</a>
</address></div>
<table align="right">
<tr>
<td><?php
if ($_SESSION['loggedIn'] == 1) {
?>
<p>Welcome, <?php echo $_SESSION['userName'] ?> (<a href="logout.php" title="Log Out">Log Out</a>)</p>
<?php
} else {
?>
<p>Please <a href="login.php">log in</a></p>
<?php } ?>
</td>
</tr>
</table><br />
<div id="ddsidemenubar" class="markermenu">
<ul>
<li><a href="home.php" title="Home Page">Home</a></li>
<li><a href="#" title="Getting Started" rel="ddsubmenuside1">Getting Started</a></li>
<li><a href="creationform.php" title="Create Character" class="select">Create Character</a></li>
<li><a href="#" rel="ddsubmenuside2" title="Members">Members</a></li>
<li><a href="newsandevents.php" title="News And Events">News And Events</a></li>
<li><a href="glossary.php" title="Glossary">Glossary</a></li>
<li><a href="topiclist2.php" title="Battle Board">Battle Board</a></li>
<li><a href="chat/chatframe.php" title="Battle Chat Lounge">Battle Chat Lounge</a></li>
<li><a href="about.php" title="About Us">About Us</a></li>
<li><a href="news.php" title="Newsletters">Newsletters</a></li>
<li><a href="invite.php" title="Invite Friends">Invite Friends</a></li>
<li><a href="topiclist.php" title="Discussion Board Forum">Discussion Board</a></li>
<li><a href="faq.php" title="Frequently Asked Questions">FAQ</a></li>
<li><a href="contact.php" title="Contact Us">Contact Us</a></li>
</ul>
</div>

<script type="text/javascript">
ddlevelsmenu.setup("ddsidemenubar", "sidebar") //ddlevelsmenu.setup("mainmenuid", "topbar|sidebar")
</script>

<!--HTML for the Drop Down Menus associated with Side Menu Bar-->
<!--They should be inserted OUTSIDE any element other than the BODY tag itself-->
<!--A good location would be the end of the page (right above "</BODY>")-->


<!--Side Drop Down Menu 1 HTML-->

<ul id="ddsubmenuside1" class="ddsubmenustyle blackwhite">
<li><a href="#" title="Chapter 1: Introduction" rel="ddsubmenuside3">Chapter 1: Introduction</a>

<ul class="smaller2"><li><a href="genre.php" title="The Magical Girl Genre">The Magical Girl Genre</a></li><li><a href="sailormoon.php" title="Bishojo Senshi Sailormoon"><em>Bishojo Senshi Sailormoon</em></a><li><a href="seriesbackground.php" title="Sailor Moon Series Background">Sailor Moon Series Background</a><ul class="smaller3"><li><a href="summary1.php" title="Season One Summary (Episodes #1 - #40)">Season One Summary</a></li><li><a href="summary2.php" title="Season Two Summary (Episodes #41 - #82)">Season Two Summary</a></li></ul></li><li><a href="roleplaying.php" title="What Is Role-Playing?">What Is Role-Playing?</a></li><li><a href="example.php" title="An Example Of Play">An Example Of Play</a></li><li><a href="size.php" title="Character Size Relationship">Character Size Relationship</a></li></ul></li>
<li><a href="creation.php" title="Chapter 2: Character Creation">Chapter 2: Character Creation</a>
<ul class="smaller4"><li><a href="flowchart.php" title="Character Creation Flowchart">Character Creation Flowchart</a></li><li><a href="gmdiscussion.php" title="GM Discussion">Step 1: GM Discussion</a></li><li><a href="outline.php" title="Character Outline">Step 2: Character Outline</a></li><li><a href="stats.php" title="Assign Stats">Step 3: Assign Stats</a></li><li><a href="attributes1.php" title="Character Attributes">Step 4: Character Attributes</a><ul><li><a href="attributes2.php" title="Scout/Knight Sub-Attributes">Scout/Knight Sub-Attributes</a></li><li><a href="attributes3.php" title="Negaverse/Dark Sub-Attributes">Negaverse/Dark Sub-Attributes</a></li><li><a href="attributes4.php" title="Neutral Attributes">Neutral Attributes</a></li></ul></li><li><a href="defects.php" title="Character Defects">Step 5: Character Defects</a></li><li><a href="derived.php" title="Derived Values">Step 6: Derived Values</a><ul class="smaller5"><li><a href="derived.php#combat" title="Combat Value">Combat Value</a></li><li><a href="derived.php#health" title="Health Points">Health Points</a></li><li><a href="derived.php#energy" title="Energy Points">Energy Points</a></li></ul></li><li><a href="background.php" title="Background Points">Step 7: Background Points</a></li></ul></li>
<li><a href="#" title="Chapter 3: Game Mechanics">Chapter 3: Game Mechanics</a>
<ul class="smaller6"><li><a href="introduction.php" title="Introduction">Introduction</a></li>
<li><a title="Combat Flowchart">Combat Flowchart</a></li>
<li><a href="dice.php" title="Dice, Stat Checks, & Combat Rolls">Dice, Stat Checks, & Combat Rolls</a><ul class="smaller7"><li><a href="dice.php#stat" title="Stat Checks">Stat Checks</a></li><li><a href="dice.php#combat" title="Combat Dice Rolls">Combat Dice Rolls</a></li></ul></li>
<li><a href="action.php" title="Taking Action">Taking Action</a></li>
<li><a href="combat.php" title="Combat">Combat</a><ul class="smaller8"><li><a href="combat.php#initiative" title="Initiative">Initiative</a></li><li><a href="combat.php#attack" title="Attack">Attack</a></li><li><a href="combat.php#noncombat" title="Non-Combat Actions">Non-Combat Actions</a></li><li><a href="combat.php#defend" title="Defend">Defend</a></li><li><a href="combat.php#damage" title="Deliver Damage">Deliver Damage</a></li></ul></li>
<li><a href="weapons.php" title="Weapons And Armor">Weapons And Armor</a></li>
<li><a href="recovering.php" title="Recovering Lost Points">Recovering Lost Points</a>
<ul class="smaller9"><li><a href="recovering.php#health" title="Health Points">Health Points</a></li>
<li><a href="recovering.php#energy" title="Energy Points">Energy Points</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="universe.php" title="Role-Playing In A Sailor Moon Universe">Chapter 4: RPing In A SM Universe</a>
<ul class="smaller10"><li><a href="japan.php" title="Japan And Tokyo">Japan And Tokyo</a></li>
<li><a href="#" title="Maps Of Japan And Tokyo">Maps Of Japan and Tokyo</a></li>
<li><a href="places.php" title="Places In Sailor Moon">Places In Sailor Moon</a></li>
<li><a href="timeline.php" title="Sailor Moon Timeline">Sailor Moon Timeline</a></li>
<li><a href="kingdom.php" title="The Moon Kingdom">The Moon Kingdom</a>
<ul class="smaller11"><li><a href="kingdom.php#light" title="The Kingdom Of Light">The Kingdom Of Light</a></li>
<li><a href="kingdom.php#members" title="Members Of The Royal Court">Members Of The Royal Court</a></li>
<li><a href="kingdom.php#planetary" title="The Planetary Kingdoms">The Planetary Kingdoms</a></li>
</ul>
</li>
<li><a href="negaverse.php" title="The Negaverse">The Negaverse</a>
<ul class="smaller12"><li><a href="negaverse.php#known" title="What Is Known">What Is Known</a></li>
<li><a href="negaverse.php#unknown" title="Speculation On What Is Unknown">Speculation On Unknown</a></li>
</ul>
</li>
<li><a href="makaiju.php" title="Planet Of Makaiju">Planet Of Makaiju</a>
<ul class="smaller13"><li><a href="makaiju.php#campaign" title="Campaign And Setting Questions">Campaign & Setting Questions</a></li></ul>
</li>
<li><a  href="crystal.php" title="Crystal Tokyo">Crystal Tokyo</a>
<ul><li><a href="crystal.php#campaign" title="A Crystal Tokyo Campaign">A Crystal Tokyo Campaign</a></li></ul>
</li>
<li><a href="nemesis.php" title="Nemesis, The Dark Moon">Nemesis, The Dark Moon</a></li>
<li><a href="life.php" title="School Life In Japan">School Life In Japan</a></li>
<li><a href="advice.php" title="Advice For The Player">Advice For The Player</a></li>
</ul>
</li>
</ul>

<!--Side Drop Down Menu 2 HTML-->

<ul id="ddsubmenuside2" class="ddsubmenustyle blackwhite smaller1">
<li><a href="heroes.php" title="Heroes">Heroes</a></li>
<li><a href="villains.php" title="Villains">Villains</a></li>
</ul>
<div id="main">
<h1>Character Creation - Successful</h1>

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("smrpg", $con);$sql="INSERT INTO scout (identity, charactername, elementofinfluence, age, birthdatemonth, birthdateday, birthdateyear, heightfeet, heightinches, bloodtype, hobbies, favoritecolor, favoritegemstone, favoritefood, leastfavoritefood, favoriteschoolsubject, leastfavoriteschoolsubject, strengths, weaknesses, goal, biography)
VALUES
('$_POST[identity]','$_POST[charactername]','$_POST[elementofinfluence]','$_POST[age]','$_POST[birthdatemonth]','$_POST[birthdateday]','$_POST[birthdateyear]','$_POST[heightfeet]','$_POST[heightinches]','$_POST[bloodtype]','$_POST[hobbies]','$_POST[favoritecolor]','$_POST[favoritegemstone]','$_POST[favoritefood]','$_POST[leastfavoritefood]','$_POST[favoriteschoolsubject]','$_POST[leastfavoriteschoolsubject]','$_POST[strengths]','$_POST[weaknesses]','$_POST[goal]','$_POST[biography]')";if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Character successfully created! Redirecting to Home page...";mysql_close($con)
?>

</div>
<address>
<a href="guestbook.php">Sign Guestbook</a> | <a href="guestbookdisplay.php">View Guestbook</a> | <a href="help.php">Help</a> | <a href="contactus.php">Contact Us</a>
</address>
</body>
</html>

 

Is there somewhere specific the code needs to be placed in order for it to work properly?

Link to comment
Share on other sites

Okay, but in the function your provided, if looks like I would be referencing $age, $day, and $month, variables that I have not already set. Don't I need to set these first? In the insert.php, I just have it inserting the values from the form, but I have not set them to variables as far as I can tell. They don't have any $ in front of any of them.

Link to comment
Share on other sites

Is there a way to tell it to always base the calculation on the year 1992 to determine the year?

 

What exactly are you trying to do?  Maybe Barand can divine your intentions, but I can't and I suspect not many other readers would understand your last post.

Link to comment
Share on other sites

Because this is going to be for younger people who may not know how to accurately figure the birthyear, and I want the year based on 1992, because that is the time period this will be set in. I'm pretty sure that this calculation can be done, it's just a matter of someone helping me figure out how to write it.

Link to comment
Share on other sites

If you are trying to find out how old they were in 1992, I suppose you would:

<?php
$howOldTheyWereIn1992 = $age - (date('Y') - 1992);
?>

BUT that will make them a negative age if they are younger than 16 (using 2008 for current year) since they weren't born yet.

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.