Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 02-10-08   #1 (permalink)
PC Gamer
 
intel ati

Join Date: Nov 2007
Posts: 108

Rep: 7 Sypher250 Unknown
Unique Rep: 5
Trader Rating: 0
Default PHP/SQL login question

Hey guys, i have a database with a table for users in it. When people register on my site it automatically puts all their info into my users table. But im trying to make a simple login for it and I cant figure out what I should be typing. I think all i need to do is have it check the table for whatever user name and password they provide. Then if it all matches it will logem in or take them to an error page. Any ideas, scripts, or good links you guys can send me?
__________________
Chuck Norris appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked about this "glitch," Norris replied, "That's no glitch."

System: Apollo Mk2
CPU
Intel Q6600
Memory
4GB DDR2 1000mhz
Graphics Card
Radeon HD 4850
Hard Drive
640GB Western Digital
CPU cooling
Xigmatek
OS
Vista Premium
Monitor
22" HP W2207
Sypher250 is offline   Reply With Quote
Old 02-10-08   #2 (permalink)
Programmer
 
stupid's Avatar
 
amd nvidia

Join Date: Jan 2006
Location: Fahaheel, Kuwait
Posts: 1,223

Rep: 144 stupid is acknowledged by manystupid is acknowledged by many
Unique Rep: 113
FAQs Submitted: 1
Trader Rating: 4
Default

you are on the right track - sounds like most of the work is already done. I am not much of a php programmer, so I can't really poitn you to any pre-made utilities... sorry.
__________________
"If there is a god, I hope he has a good excuse"
Woody Allen

System: Minazo
CPU
Opteron 1210
Motherboard
Biostar TForce 550 SE
Memory
2x1GB G.Skill DDR2 800
Graphics Card
eVGA 8800GT
Hard Drive
500GB 16MB Buf Samsung
Power Supply
Corsair HX520W Modular
Case
CoolerMaster Centurion 5
CPU cooling
CoolerMaster GeminII & Scythe SFF21Ds
GPU cooling
Accelero S1 & Scythe SFF21D
OS
XP Pro SP2
Monitor
Dual monitors: 22" & 19" Widescreens
stupid is offline   Reply With Quote
Old 02-11-08   #3 (permalink)
AMD Overclocker
 
Starholdest's Avatar
 
amd nvidia

Join Date: Mar 2007
Location: █♣█
Posts: 925
Blog Entries: 1

Rep: 43 Starholdest is acknowledged by some
Unique Rep: 38
Hardware Reviews: 1
Trader Rating: 0
Default

basically

mysql_query("SELECT `password` FROM `users` WHERE `username` = '".$_POST['username']."'");
if($_POST['password'] == $row['password'])

That's basically the mysql_query and the if line. If you're not using salts, already, I suggest using them right now, or else you're in big risk of getting hacked. There's a good tutorial here:

http://www.phpit.net/article/handlin...ds-safely-php/

Basically when the user registers, you put their salted password (as shown below) and the salt ($salt) into the db (put the salt into a different row), it's just like:

$salt = rand(1,2000)."xK]=3qd".rand(1,2000);
$pass_salted = md5(sha1($salt.$_POST['password'].$salt));

If you find it confusing or need anymore help just post here or PM me.
__________________

My s939 rig build log thread - 4600+ @ 2.8Ghz stable


Aumotocnic "An unfortunate member of the overclock.net insomnia club"

Quebec Overclockers - 8019 in 3dMark06

s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741
@ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669

System: Beast from the East
CPU
AMD x2 4600+ @ 2.8Ghz
Motherboard
Asus A8N-SLI SE
Memory
2GB Kingston Value DDR400
Graphics Card
Asus 8800GTS 320MB
Hard Drive
80G Seagate SATA
Sound Card
SoundBlaster Audigy SE
Power Supply
Thermaltake Purepower 500W
Case
Antec 900 (modded)
CPU cooling
AS5 + Zalman CNPS9700 LED
GPU cooling
Stock
OS
Windows Vista Ultimate
Monitor
Samsung Syncmaster 730B (17" yay!)
Starholdest is offline Starholdest's Gallery   Reply With Quote
Old 02-12-08   #4 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Posts: 290

Rep: 29 Dismounted is acknowledged by some
Unique Rep: 20
Folding Team Rank: 572
Hardware Reviews: 2
Trader Rating: 0
Default

I nearly threw up reading that query. Are you trying to invite hackers into his website or something? Although this isn't the most elegant system, try something more like:

mysql_query("SELECT `password` FROM `users` WHERE `username` = '" . mysql_real_escape_string($_POST['username']) . "'");
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
ASUS EAH3870 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
Stock
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 02-12-08   #5 (permalink)
AMD Overclocker
 
Starholdest's Avatar
 
amd nvidia

Join Date: Mar 2007
Location: █♣█
Posts: 925
Blog Entries: 1

Rep: 43 Starholdest is acknowledged by some
Unique Rep: 38
Hardware Reviews: 1
Trader Rating: 0
Default

Quote:
Originally Posted by Dismounted View Post
I nearly threw up reading that query. Are you trying to invite hackers into his website or something? Although this isn't the most elegant system, try something more like:
I was writing it quick...I didn't intend for him to use it. Also you don't need dots in between the quotes unless you're connecting two things. Thanks for correcting me, though.
__________________

My s939 rig build log thread - 4600+ @ 2.8Ghz stable


Aumotocnic "An unfortunate member of the overclock.net insomnia club"

Quebec Overclockers - 8019 in 3dMark06

s939 Manny 4600+ @ 2809Mhz @ 1.425V (9 hours Orthos blend test stable - 24/7 Usage) - http://valid.x86-secret.com/show_oc.php?id=289741
@ 2945Mhz @ 1.45V (YAY! - Not stable, doh!) - http://valid.x86-secret.com/show_oc.php?id=276669

System: Beast from the East
CPU
AMD x2 4600+ @ 2.8Ghz
Motherboard
Asus A8N-SLI SE
Memory
2GB Kingston Value DDR400
Graphics Card
Asus 8800GTS 320MB
Hard Drive
80G Seagate SATA
Sound Card
SoundBlaster Audigy SE
Power Supply
Thermaltake Purepower 500W
Case
Antec 900 (modded)
CPU cooling
AS5 + Zalman CNPS9700 LED
GPU cooling
Stock
OS
Windows Vista Ultimate
Monitor
Samsung Syncmaster 730B (17" yay!)
Starholdest is offline Starholdest's Gallery   Reply With Quote
Old 02-14-08   #6 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Posts: 290

Rep: 29 Dismounted is acknowledged by some
Unique Rep: 20
Folding Team Rank: 572
Hardware Reviews: 2
Trader Rating: 0
Default

Quote:
Originally Posted by Starholdest View Post
I was writing it quick...I didn't intend for him to use it. Also you don't need dots in between the quotes unless you're connecting two things. Thanks for correcting me, though.
The word you're looking for is concatenating. I AM concatenating in the posted code.
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
ASUS EAH3870 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
Stock
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 02-14-08   #7 (permalink)
Programmer
 
intel ati

Join Date: Nov 2006
Posts: 1,355

Rep: 91 version2 is acknowledged by some
Unique Rep: 74
Trader Rating: 2
Default

I was going to post code, but the forums barked at me:
[code]
Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: ame_substitute(4, &quot;$result = mysql_query(\&quot;SELECT `username`, `password` FROM `users` WHERE `username` = \'\&quot;.$_POST[\'username\'].\&quot;\' AND `password` = BINARY \'\&quot; .$_POST[\'password\']. \&quot;\'\&quot; if (mysql_num_row($result) == 0) { // Successfully logged in. }&quot;, &quot;&quot;, $subbed) in /home/over/public_html/includes/ame_bbcode.php on line 192[/quote]

Anyway, basically you should check to see if rows are returned, but check for password matching (as "binary")
__________________
System: Duo
CPU
Core 2 Duo E6600 B2
Motherboard
Asus P5B Deluxe
Memory
G.SKILL HZ 2x1gb DDR2 800
Graphics Card
Sapphire x1950pro
Hard Drive
WD 640gb, Maxtor 160gb
Sound Card
Audigy 2 ZS
Power Supply
FSP 450W
Case
Ultra Aluminus
CPU cooling
Freezer Pro 7
GPU cooling
Stock
Monitor
20.1'' SOYO LCD (Wide)
version2 is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 11:41 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.17241 seconds with 9 queries