MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 15th, 2004, 08:17 AM
Matt@Array Matt@Array is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 Matt@Array User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP, MySQL check

Okay, im new to working with databases using PHP. I want to make a simple user database, and have people sign in to look at a page;

so I want to do something like this on the page thats password protected
Code:
<?
if ($_POST['username'] == $username && $_POST['password'] == $password)
{
include 'site.php'
}
else
{
include 'wrongpass.php'
}
?>

(wrote this code kind of quick)

Okay, my question is, how can I set $username and $password to check the mysqldtabase fields and mach them up? Is this the right approach or should I be doing it another way all together?

Any help is appreciated

Reply With Quote
  #2  
Old January 15th, 2004, 09:25 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
If you want real security, you'll need to take another tack. For example, say I either spider your site or make a wild guess that you've got "secure" content on a page called site.php. If I load that page directly rather than going through the user/password page, I've bypassed your security. The moral is that you should always protect the content itself and not the wrapper around it. So the logic should be (in plain English): "If username and password are correct, print out the content; else include or print the error page."

As for building the user system, I believe there are several tutorials on the site that should be a good start. You might also go to php.net and search for "mysql_query" in the function list. I advise you to familiarize yourself with all the mysql functions before starting work, as this can save you much time and anguish later.

Reply With Quote
  #3  
Old January 15th, 2004, 02:31 PM
Matt@Array Matt@Array is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 Matt@Array User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Okay thanks, i understand the problem with going around

Reply With Quote
  #4  
Old January 15th, 2004, 08:47 PM
Matt@Array Matt@Array is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 Matt@Array User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Code:
$usercheck = mysql_query("SELECT username FROM users WHERE username=$loginid;");


should this return vaules of $loginid from the dtabase?

Reply With Quote
  #5  
Old January 16th, 2004, 08:16 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
> should this return vaules of $loginid from the dtabase?

This will return the username if its equal to $loginid
By the way, you don't need semi-colons in the mysql_query()... in fact, that may return an error...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > PHP, MySQL check


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway