aebstract Posted February 29, 2008 Share Posted February 29, 2008 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. Quote Link to comment Share on other sites More sharing options...
tinker Posted February 29, 2008 Share Posted February 29, 2008 use two tables: users (id, name, pass, acc_id) accounts (acc_id, details, details, details) This way you can link multiple user logins to an account... Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 29, 2008 Author Share Posted February 29, 2008 So you're saying to generate the dropdown based on the accounts table, but match logins based on the users table? I could do that, shouldn't be too much work. Thanks for the idea. Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 29, 2008 Author Share Posted February 29, 2008 <?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. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted February 29, 2008 Share Posted February 29, 2008 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 Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 29, 2008 Author Share Posted February 29, 2008 I know how to match it but nevermind anyway, figured out what I had wrong. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.