session - PHP Post, Redirect, Get Issues -
i created form takes birthday , spits out bunch of data relative date. works great in chrome, i'm not getting output in browsers firefox , safari. i'm not receiving php errors, think problem ff & safari not setting session variables intended. i'm new php first time using method, here's i'm using:
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: " . $_server['request_uri']); //header("location: " . $_server['request_uri']); 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 = 0; $day = 0; $year = 0; }
form
<form method="post" id="birthday-form" action="/calculator/"><div class="dobrow"><div class="dobmonth"> <select name="dob-month"><option value="">month</option><option value="1">january</option><option value="2">february</option><option value="3">march</option><option value="4">april</option><option value="5">may</option><option value="6">june</option><option value="7">july</option><option value="8">august</option><option value="9">september</option><option value="10">october</option><option value="11">november</option><option value="12">december</option></select></div><p></p><div class="dobday"><input type="text" name="dob-day" maxlength="2" placeholder="day"/></div><p></p><div class="dobyear"><input type="text" maxlength="4" max="2015" name="dob-year" placeholder="year"/></div><p></p><div class="dobsubmit"><input type="submit" name="submit" value="calculate"/></div><p></div><p></p></form>
the line after session start thrown in there check php errors, , i'm not receiving any. receiving undefined variable errors $month, $day, , $year on initial page load before sessions had been set, why set 0 default.
if me figure out why isn't working correctly i'd appreciate help. i've been trying function work correctly weekend, i'm struggling , not sure else do. in advance.
Comments
Post a Comment