|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
MySQL/PHP Query question
I've decided to create a comment script for a beginning project. Right now, I'm working on the registering part of the script. My problem is checking to see if the username already exists within the database. Here's the code I'm using right now:
PHP Code:
|
|
#2
|
|||
|
|||
|
Re: MySQL/PHP Query question
Two suggestions:
1. Instead of using ($result !="") use: PHP Code:
|
|
#3
|
||||
|
||||
|
Re: MySQL/PHP Query question
Now, I'm no PHP-guru, actually I've never used it before ... but from my experience using perl/cgi I tend to be a bit paranoid. But safely so. The cardinal rule is never trust the user; taint check, taint check, taint check! Not being familiar with PHP, like I said, I don't know if it's possible to do any sort of attack against a script of this nature, but I suspect there is. (Granted the short snippet you show may not suceptible, it's still a good idea to check your input.) E.g., if someone is entering a user-name make sure it only contains allowed characters and is correctly formatted. In perl, anyway, you'd be suprised how easy it is to pass 'rm -r .*' as an argument to something and watch for disastrous effects!
Just a friendly security reminder ... it never hurts to start good habbits early (since you said you were learning PHP). Maybe someone more experienced can comment about specific security woes that you'll have to look out for. But remember that paranoia is good. |
|
#4
|
||||
|
||||
|
Re: MySQL/PHP Query question
Change
PHP Code:
PHP Code:
If you need any more MySQL or PHP help, email me, go to my team's website (which was built by me using PHP/MySQL), or check out this project I'm heading, supermod.org. |
|
#5
|
|||||
|
|||||
|
Re: MySQL/PHP Query question
Thank you all for your help. But while waiting for a reply, I was messing around with it, trying to see if I could fix it myself. I still have the same trouble, and here's my code now:
PHP Code:
|
|
#6
|
|||
|
|||
|
Re: MySQL/PHP Query question
Did you try the mysql_num_rows suggestion above?
|
|
#7
|
|||||
|
|||||
|
Re: MySQL/PHP Query question
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question of the Week [05-02-04]: The Very Merry Month of May | EddieMcD | Rumor Mill | 10 | 05-05-2004 14:02 |
| MIM's question of the day on programming. | Gene F | Programming | 3 | 24-02-2004 16:32 |
| A question about control system options | computhief263 | Control System | 7 | 04-02-2004 14:46 |
| MySQL query question | Jack | Website Design/Showcase | 9 | 02-02-2003 00:11 |