Jump to content

how would you..


aebstract

Recommended Posts

I have a members area on a website, the login is by a dropdown which pulls all the users from the database. I need a way to have it so that I can have to different passwords for the same user. Also, there is a shopping cart on the site, I need to be able to have a way to tell which user was logged in when they completed checkout. So basically, 2 passwords for same account, both work and do the same thing but gotta track as being two different people.

Link to comment
Share on other sites

<?php
if(isset($_SESSION["id"]))
{
  header("Location: /accounthome/");
  exit();
}

//Doesn't this happen in the include('connect.php') in index.php?
mysql_connect("localhost","berryequipment","gU8Kso8Y") or die(mysql_error());
mysql_select_db("berryequipment_net_db");

if(isset($_POST['submit']))
{
  if(empty($_POST['password']))
  {
    $error .= 'You must fill in a password <br />';
  }
  if(!strlen($error))
  {
    $result = mysql_query("SELECT * FROM `plants` WHERE `id` = '".mysql_real_escape_string($_POST['dropdown'])."' AND `password` = '".md5($_POST['password'])."'")
      or die("Query error: ".mysql_error());
    if(mysql_num_rows($result) == 0)
    {
      $error .= "The pasword you entered did not match the plant location you chose.";
    }
    else
    {
      $worked = mysql_fetch_array($result);
      $_SESSION["id"] = $worked['id'];

      header("Location: /accounthome/");
      exit;
    }
  }
}

$content .= '<center><table><tr><td><form action="/login/" method="post">Location: </td><td><select name="dropdown">';
$result = mysql_query("SELECT * FROM `plants` ORDER BY `plantloc` ASC") or DIE(mysql_error());
while($r = mysql_fetch_array($result))
{
  $id = $r['id'];
  $plantloc = $r['plantloc'];
  $content .= "<option value=\"{$id}\">{$plantloc}</option>\n";
}
$content .= '</select></td></tr><tr><td>
Password:
</td><td>
<input type="password" name="password" size="6" />
</td></tr><tr><td></td><td>
<input type="submit" name="submit" value="login" />
</td></tr></table></center></form>';
?>

 

This is my login script, and now that I am adding a new table in this format:

 

unique_id | plant | email | password

 

plant = the unique id for each plant in the "plants" table.

 

What do I need to do to get my login setup so that this all runs smoothly like it was before the addition of the table. Just some guidance is all I am looking for, thanks.

Link to comment
Share on other sites

comma seperated m8, use emplode(password, ", ") to store them

 

and use explode array=explode(field, ",") to read them

 

or create another table with a one to manu relation from the user to the table 1 user can have many passwords then just seartch to see if the entered pwd exists in the passwords for that user

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.