$7 By peterj On 2016-11-23 09:17:24 In Science/Technologiez
So you want to program a website in php and sql...
Here's a little advice to any budding web developers:
1: <?php session_start() ?> must be the first thing on every page that uses the $_SESSION array. I don't care if it works anywhere in xampp. Just trust me. Speaking of...
2: xampp is way more forgiving than the server you will probably be uploading your code onto. Run some tests to figure out what works on THAT server before you write too much code.
3: Not all versions of sql let you use current_timestamp as a default value for datetime columns. Those columns should be timestamp columns instead.
4: Figure out whether your server's version of php uses magic quotes before you write too much code. if it doesn't, you're good. If it does, learn how to turn magic quotes off. if you can't turn them off for some reason (like your webhosting service doesn't let you), you need to write your code to deal with them, which is much easier to do from the start.
5: always test every file BEFORE you upload it to the server. A missing semicolon or errant curly brace can bring your entire website to a grinding halt.
6: just use sql prepared statements for everything, regardless of where the data came from. Concatenating sql queries is asking for trouble.
7: As you test your site, think like your grandparents. What would they click? What would confuse them? It's easy to overlook your own glitches because you know how the site is supposed to work. Learn to see through the eyes of a user who doesn't know ANYTHING.
I hope these tips are helpful to anybody interested in doing this kind of work. I wish I had found a forum post with all this stuff in it when I started.
1: <?php session_start() ?> must be the first thing on every page that uses the $_SESSION array. I don't care if it works anywhere in xampp. Just trust me. Speaking of...
2: xampp is way more forgiving than the server you will probably be uploading your code onto. Run some tests to figure out what works on THAT server before you write too much code.
3: Not all versions of sql let you use current_timestamp as a default value for datetime columns. Those columns should be timestamp columns instead.
4: Figure out whether your server's version of php uses magic quotes before you write too much code. if it doesn't, you're good. If it does, learn how to turn magic quotes off. if you can't turn them off for some reason (like your webhosting service doesn't let you), you need to write your code to deal with them, which is much easier to do from the start.
5: always test every file BEFORE you upload it to the server. A missing semicolon or errant curly brace can bring your entire website to a grinding halt.
6: just use sql prepared statements for everything, regardless of where the data came from. Concatenating sql queries is asking for trouble.
7: As you test your site, think like your grandparents. What would they click? What would confuse them? It's easy to overlook your own glitches because you know how the site is supposed to work. Learn to see through the eyes of a user who doesn't know ANYTHING.
I hope these tips are helpful to anybody interested in doing this kind of work. I wish I had found a forum post with all this stuff in it when I started.