Jump to content

rizlmilk

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rizlmilk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Before I tried PFMaBiSmAd's suggestion I tested the site a little more and it now seems to work fine. I didn't change anything at all but it is now working perfectly. Thanks for all the help everyone. Don't be surprised if I'm back though
  2. I know I'm not actually reading the cookie in that provided code, I was just proving that the setcookie area of code was reached. The remaining pages use isset to check the cookie. I'm using Ubuntu 9.10. Both FireFox and Chrome don't log in correctly.
  3. After a little more testing I have found out that it works totally fine in IE6, but FireFox 3.5 just sets the cookie whenever it feels like it. I am printing either "loggedin = 1" if the username and password matched and therefore the cookie was set, otherwise it will print "loggedin = 2" to indicate the cookie wasn't set. In my testing it will always show "loggedin = 1" when I have correctly entered a valid username and password combo, but it seems to randomly decide whether the cookie will be set. As I said earlier, IE6 always sets the cookie correctly but FireFox doesn't always set the cookie. PFMaBiSmAd: I have read the documentation but, like usual, a lot of it typically goes over my head. The best way to learn something for me is to play with it...which leads to questions...which leads me here. Playing around with the remaining parameters seemed to get me further away. <?php $username = $_POST["username"]; //setcookie("grocerycookie", $username, time()+3600); mysql_connect("_", "_", "_") or die(mysql_error()); mysql_select_db("_") or die(mysql_error()); $username = strtolower($_POST['username']); $password = $_POST['password']; $data = mysql_query("SELECT * FROM userpass WHERE username='$username'") or die(mysql_error()); $loggedin = 0; while($info = mysql_fetch_array($data)) { if ($password == $info['password']) { setcookie("grocerycookie", $username, time()+3600); $loggedin = 1; } } if ($loggedin == 1) { echo "loggedin = 1"; //the cookie should be set } else { echo "loggedin = 2"; } ?> Try it out for yourself: http://blowthecart.com/grocery/login.php Username: sho Password: sho or register your own user/pass. Hopefully this information will help. Thanks for any suggestions.
  4. I'm currently playing around with a user system with login and registration. I'm trying to use cookies to log the user in but the cookie either doesn't set or it sets after I travel through a few pages. Also, when I use isset($_COOKIE(name)) it sometimes doesn't return that it is set even though it is. login.php (the username and password request page which I am currently using to display if a cookie is set) <?php if (isset($_COOKIE["grocerycookie"])) { $username = $_COOKIE["grocerycookie"]; echo "You are logged in, <b>$username</b><br />"; } else { echo "You have not been logged in."; } ?> login2.php (sets the cookie) <?php mysql_connect("*", "*", "*") or die(mysql_error()); mysql_select_db("*") or die(mysql_error()); $username = strtolower($_POST['username']); $password = $_POST['password']; $data = mysql_query("SELECT * FROM * WHERE username='$username'") or die(mysql_error()); while($info = mysql_fetch_array($data)) { if ($password == $info['password']) { setcookie("grocerycookie", $username, time()+3600); } } Am I setting the cookie wrong or checking for it wrong?
  5. I would say a good example of using ul and li is when you want to display a custom bullet image for a list with css. It may seem obvious, but before I realized it I was using an img tag to show an image before each item in a list. Using ul and li instead of img cuts down file size a hell of a lot.
×
×
  • 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.