Jump to content

jcpd910

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by jcpd910

  1. The topic was solved by QuickOldCar who I messaged privately.
  2. jcpd910

    PHP Login

    You need to change dbUsers in the scripts to dbusers.
  3. I just realized I don't really have any way of know if this code is working, can you give me a script that says something like: Welcome (username)! so I know whether or not you can stay logged in? I've tried other codes but they don't work with my scripts.
  4. Don't use <?php> than? just copy and paste: session_start(); ?
  5. Ugh! This is so hard to understand. I am using <?php session_start(); ?> At the top of my index page but I don't understand what you mean why setting and unsetting.
  6. Can you give me the coding for that? I don't know what to put in myValue.
  7. That will still require them to log in right? I don't want guests.
  8. I'm not sure what you mean. I'm new to scripts like this.
  9. No. I tried putting them in, but I don't have the exact code.
  10. Here is the problem, people can sign up and log in, but the second they leave the: Welcome (whatever username)! page, they get logged out. Here is the login script. <?php session_start(); // Check if he wants to login: if (!empty($_POST[username])) { require_once("connect.php"); // Check if he has the right info. $query = mysql_query("SELECT * FROM members WHERE username = '$_POST[username]' AND password = '$_POST[password]'") or die ("Error - Couldn't login user."); $row = mysql_fetch_array($query) or die ("Error - Couldn't login user."); if (!empty($row[username])) // he got it. { $_SESSION[username] = $row[username]; echo "Welcome $_POST[username]! You've been successfully logged in. <a href=\"/index.php\" title=\"Click here to go back to the homepage.\">Home Page</a></li></ul>";; exit(); } else // bad info. { echo "Error - Couldn't login user.<br /><br /> Please try again."; exit(); } } ?> <html> <head> <title>Login</title> </head> <body> <form action="login.php" method="post"> <table width="75%" border="1" align="center" cellpadding="3" cellspacing="1"> <tr> <td width="100%"><h5>Login</h5></td> </tr> <tr> <td width="100%"><label>Username: <input type="text" name="username" size="25" value="<? echo $_POST[username]; ?>"></label></td> </tr> <tr> <td width="100%"><label>Password: <input type="password" name="password" size="25" value=""></label></td> </tr> <tr> <td width="100%"><input type="submit" value="Login!"></td> </tr> <tr> <td width="100%">Don't have an account? Click <a href="/register.php">Here</a> To register.</td></tr> </table> </form> </body> </html>
×
×
  • 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.