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
https://forums.phpfreaks.com/topic/93696-how-would-you/
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
https://forums.phpfreaks.com/topic/93696-how-would-you/#findComment-480149
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
https://forums.phpfreaks.com/topic/93696-how-would-you/#findComment-480162
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.