Code2Design.com

User login

The Layout

Programming

Graphic Design

Resources

Navigation

C2D Projects

Unsystematic Affiliates

DNSandIP AK Pro Tarnic T-Tutorials 

Change Language

Who's online

There are currently 0 users and 3 guests online.

Login Code

I have been attempting for about the last 30 hours to get a login code that works made and I'm 1/2 way there and now I need help. I have this code:

<?php
$login 
mysql_query("SELECT `user_id`, `username`, `password`, `email`, `status` FROM `users` WHERE `email` = '$_POST[email]' AND `password` = '$_POST[password]' LIMIT 1");
while(
$log mysql_fetch_array($login  ))
  {
 
session_start();
 
$_SESSION['user_id'] = $log[user_id];
 
$_SESSION['username'] = $log[username];
 
$_SESSION['password'] = $log[password];
 
$_SESSION['email'] = $log[email];
 
$_SESSION['status'] = $log[status];
  }
$result mysql_query("SELECT `user_id`, `username`, `password`, `email`, `status` FROM `users` WHERE `email` = '$_POST[email]' AND `password` != '$_POST[password]'");
while(
$res mysql_fetch_array($result  ))
  {
      echo 
"Sorry you entered an incorrect password, please try again";
  }
if(
$_SESSION['email'] == $_POST['email'])
{
    if(
$_SESSION['password'] == $_POST['password'])
    {
       
mysql_query("UPDATE `users` SET `status` = '1' WHERE `email` = '$_POST[email]' AND `password` = '$_POST[password]'");
    }
    else if(
$_SESSION['password'] != $_POST['password'])
    {
        echo 
"You entered an invalid password";
    }
}
else if(
$_SESSION['email'] != $_POST['email'])
{
    echo 
"You entered an invalid email";
}
?>

And it will only work if there is 1 account in the database and of course the purpose of one account is nothing and [i]I cannot figure out why it only works with one account. If anybody can, could you tell me what needs to be done?


Submitted by Navigator on February 17, 2008 - 12:43am.
printer friendly version

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <br /> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options



Like what you see?

Why not add more? C2D is looking for other Christian Web Masters who would like to help write articles for this site. If you have expericance in FLASH, CSS/HTML, PHP/MySQL, PhotoShop/GIMP, Blender, Javascript, or just General Design - our users would love to hear what you have to say. Contact Us

delicious   digg   reddit   magnoliacom   newsvine   furl   google   yahoo   technorati