PDA

View Full Version : user profile form


ibolui
05-26-2008, 02:04 AM
hi, i am facing a weird problem with my first attempt at flex, php and mysql. please pardon me if this is not the correct place to post my question.

i had a form created using flex and json, with php as the backend. below are segments of my codes..


//get the raw JSON data and cast to String
var rawData:String = String(event.result);
var user = JSON.decode(rawData);

first_name.text = user.first_name;
last_name.text = user.last_name;
email.text = user.email;

if (user.gender == "male") {
male.selected = true;
} else {
female.selected = true;
}

var bday:Date = new Date(user.birthday);
day.selectedIndex = bday.getDate() - 1;
month.selectedIndex = bday.getMonth();
year.selectedIndex = year_array.indexOf(bday.getFullYear().toString());

........



echo json_encode($_SESSION['user']);


when i first load the page, everything is being populated correctly on the flex frontend. however, when i refresh the page using f5, the birthday fields are incorrect. in the sense that it becomes 1 jan 1970.

i tried to print out the value of user.birthday and it is indeed 1 jan 1970. but i am not sure why it has become this value..

razvanpat
05-26-2008, 05:50 AM
I think this has to do with your php or browser cach. You should run the php in a browser and check the JSON output. You should also clear your browser cache and try again, it might be that the browser stored this value from a time before you correctly implemented the birthday.

ibolui
05-29-2008, 02:16 AM
hmmm yup. i found out that is my php codes problem. for info, because i used a user class, and apparently i need to clone the class instead of just $temp = $user, as modifing $temp will have impact on $user..