Moobs
Regular Member
- Jan 30, 2015
- 276
- 24
I created a simple birthday calculator that allows a user to submit their birthday, and then a bunch of facts relative to that date gets spit out. Everything works as intended in chrome, but not in firefox or safari. I'm not receiving any errors. The page gets redirected as it should when the form is submitted, but the form data is be placed into the $_POST array and then set to a session variable as it should. I have other forms on my site that work with all browsers, so I'm not sure where I've gone wrong.
This is how I'm passing the $_POST data to $_SESSION:
Here's how I'm creating the form:
I've been struggling with this all day, any help would be greatly appreciated.
This is how I'm passing the $_POST data to $_SESSION:
PHP:
session_start();error_reporting(E_ALL); ini_set('display_errors',1);
if(count($_POST) > 0) {
$_SESSION['dob-month'] = $_POST['dob-month'];
$_SESSION['dob-day'] = $_POST['dob-day'];
$_SESSION['dob-year'] = $_POST['dob-year'];
if(isset($_POST['submit'])){
$_SESSION['submit'] = 1;}
header("HTTP/1.1 303 See Other");
header("Location: https://$_SERVER[HTTP_HOST]/calculator/");
die();
}
elseif (isset($_SESSION['dob-month'])||isset($_SESSION['dob-day'])||isset($_SESSION['dob-year'])){
$month = $_SESSION['dob-month'];
$day = ltrim(sanitizeNumInput($_SESSION['dob-day']),'0');
$year = sanitizeNumInput($_SESSION['dob-year']);
$submit = $_SESSION['submit'];
/*
Put database-affecting code here.
*/
session_unset();
session_destroy();
}else{
$month = null;
$day = null;
$year = null;
}
PHP:
echo '
<div class="calc-holder">
<form method="post" action="/calculator/">
<div class="dobRow">
<div class="dobMonth">
<select name="dob-month">
'.$monthOptions;
while($i <= 12){
foreach($monthList as $key => $val){
if($i != $month){
echo '<option value="'.$key.'">'.$val.'</option>';}
$i++;
}
}
echo '
</select>
</div><!--end dobMonth-->
<div class="dobDay"><input type="text" name="dob-day" maxlength="2" '.$dayHolder.'/></div><!--end dobDay-->
<div class="dobYear"><input type="text" maxlength="4" max="'.date('Y').'" name="dob-year" '.$yearHolder.'/></div><!--end dobYear-->
<div class="dobSubmit"><input type="submit" name="submit" value="Calculate"/></div><!--end dobSubmit-->
</div><!--end dobRow-->
</form>
</div><!--end calc-holder-->';
I've been struggling with this all day, any help would be greatly appreciated.
Last edited: