1. Home
  2. Computing & Technology
  3. PHP / MySQL

Pregnancy Due Date Calculator

By , About.com Guide

2 of 2

Collecting The Date

<i>Please enter the first day of your last menstral cycle</i><br>
<form action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "GET">
<select name="month">
<option value="1">January</option>
<option value="2">February</option>
//shortened...
<option value="11">November</option>
<option value="12">December</option>
</select>

<select name="day">
<option value="1">1</option>
<option value="2">2</option>
//shortened...
<option value="30">30</option>
<option value="31">31</option>
</select>

<select name="year">
<option value="00">2000</option>
<option value="01">2001</option>
//shortened...
<option value="14">2014</option>
<option value="15">2015</option>
</select>
<br/>
<input type = "hidden" name = "go" value="1" />
<input type = "submit" name = "Calculate"/>
</form>
Please note that this code has been shortened but the full script code can be downloaded if needed.

This HTML is a form that submits back to itself using $_SERVER['PHP_SELF']. It allows the expectant parents to enter in the date of the last menstrual cycle. We would place this code below the PHP code we learned on the previous page. The date entered here is then used in our PHP calculation. We also pass one hidden value in this form, for the variable 'go', so that our script will know to execute.

View Full Code

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. PHP Pregnancy Calculator - PHP Due Date Calculator

©2009 About.com, a part of The New York Times Company.

All rights reserved.