Page 3 of 3

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 10:24 pm
by jaad
would removing trim() fix the problem? or htmlentities? but how can I protect it from sql injection. I thought this block what about sanitizing the date before being process?

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 10:26 pm
by Celauran
No. The problem is that $dob is defined in two places, with the second overwriting the first. Comment out that line entirely and see what happens.

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 10:35 pm
by jaad
ok it diffidently made a difference. I can enter a date 1999-12-22 and it works and gets entered in database correctly, I can also enter 22-12-1999 and it also gets enter correctly the only one that doesn't work and 12-22-1999 where it say "this is not a valid date (from the error string that you provided me. ) are we in business with that? should that suffice and be good enough so I won't get into trouble in the long run? I am not looking for perfection and catch every potential variation. as long as I can use the date as date in the future is all that mater to me?

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 10:37 pm
by Celauran
Take a look at the parseDate() function I posted earlier in the thread (top of page 2?). It should handle yyyy-mm-dd, dd-mm-yyyy, mm-dd-yyyy, and mm/dd/yyyy

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 10:47 pm
by jaad
ok I will thanks a million-million million times over and over and more on top.... You have no idea how hard this been I spent 2 days a half trying to figure this one one. thank you. one last question:

you know where I wrote $dob =htmlentities ($_post['dob']) line.... I though this block was to return all input data into their html entities so it doesn't get passed in in case of sql injection..... I wrote this script part of a series of tutorial that shows you how to write PDO style. it's all nice these tutorial but they dont explain much aside from saying we are going to use this function and next we use this function and so on.... there is no real explanation why the authot decided to write the way he did and as you can see, if had understood the reason for this block better I could have potentially caught the error. is there a place wehre you can actually learn about hte theory of php? I dont mean the function. I mean the logic, the steps to follow, the worflow, how to analyze a situation and figuring out on paper what I need to do first and then find the functions that I will need to build it? I am a trademan. if you ask me to build an addition to your home I will lay it out on paper first, do a take off list of hte material I will need and then write a project schedule for it. is there such a thing when writing codes?

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 11:01 pm
by Celauran
That's how code should be written IMO. You should have a very good idea of exactly what you want to do each step of the way before you write any code at all. You can use flowcharts, sketches, pseudo code or whatever else works for you. I use all of the above, depending on the complexity of the task.

As tutorials go, there is an absolute ton of terrible PHP tutorials out there and, when you're learning, it's tough to separate the wheat from the chaff. PHP the Right Way is a good resource, but I don't know if it has much in the way of step by step examples. You've admitted you're still learning the basics, yet I see you using PDO, prepared statements, classes.. I'd stick with whatever you're using now. When you encounter something you don't understand, ask.

Re: different date format in different browsers

Posted: Fri Jan 10, 2014 11:03 pm
by Celauran
jaad wrote:you know where I wrote $dob =htmlentities ($_post['dob']) line.... I though this block was to return all input data into their html entities so it doesn't get passed in in case of sql injection.....
Prepared statements mitigate the risk of SQL injection.

Re: different date format in different browsers

Posted: Sat Jan 11, 2014 5:07 am
by jaad
thanks a bunch for all your help... Oh and by the way. I was born in Valleyfield... lived several years in MTL too corner - Henrie Bourassa and Christophe Colon lol when I worked in Laval