Jump to content

fael097

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fael097's Achievements

Member

Member (2/5)

0

Reputation

  1. actually I don't know why not to use sessions. guess I learned with cookies some time ago. I fixed my problem by simply adding a header after setting the cookie. setcookie("User", "value", time()+3600); header("location: admin.php?ref=login"); that would refresh the page again, and therefore it could properly check if cookie has been set. same thing worked with logout. but now that you mentioned, it would be better to use sessions indeed. I'd still have to use cookies if I wanted a "remember me" option, right? suggestions?
  2. ok, so I found out that you can't set the cookie and retrieve it's value on the same request, that's why you need to refresh it twice. but how do i do this then? what's a workaround for that?
  3. thanks, and yeah, I just made both fields "admin" as a placeholder. but that didn't fix the problem. when I enter username and password, and press login, it runs form action, fields reset, but it doesn't login. cookies are set, but page is still the same. then if I press again, or simply refresh the page or even press enter on adress bar again, page changes, and I can see that I'm logged in, and the "hello administrator" message. then if I press logout, same thing. the hello page will still be there, until I press logout a second time, or refresh my page. and I have no idea why that's happening, but no errors or anything. I tried this on my local xampp server, and on an online host, same thing on both, so it's my code
  4. hi, I'm coding a website, after being away from php for a while, and there's this simple thing that's driving me crazy. I made a simple login system to test, and I have to refresh the page twice so it becomes active, and I can't figure out why. what's wrong with this code? (keep in mind that it's just a test, I plan to get username from database, send encrypted info to cookies, and all that, but after I get this working) <?php if (isset($_POST['submitlogin'])) { if ((($_POST['username'])&&($_POST['password']))=="admin") { setcookie("user", "Administrator", time()+3600); } else { $loginerror="1"; } } if (isset($_GET['logout'])) { setcookie("user", "", time()-3600); } ?> <html> <head> </head> <body> <?php if (isset($_COOKIE['user'])) { echo "Hello, ".$_COOKIE['user']; ?> <br /><a href="?logout=yes">Logout</a> <?php }else{?> <form action="" method="post"> <input name="username" type="text" /><br /> <input name="password" type="password" /><br /> <input name="submitlogin" type="submit" value="Login" /> </form> <?php }?> </body> </html> thanks for any help!
  5. hi, im making a simple blgo system, and i'd like to show a list of the last ten months, so the user can click the month name, and it will open the blog page with all the posts from that month, just like we usually see in blogs. any ideas? thanks in advance
  6. I made a simple test for debugging, heres my code: (I typed "ácéntôão" e "tôrrãodeaçúcar" directly on html for testing, those are exactly the same words I've put on my database.) <?php session_start(); $host_db="localhost"; $name_db="test"; $login_db="root"; $pass_db="123456"; $conn_db=mysql_connect($host_db, $login_db, $pass_db)or die("Could not connect. ".mysql_error()); $select_db=mysql_select_db($name_db, $conn_db)or die("Could not select database. ".mysql_error()); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> ácéntôão<br /> tôrrãodeaçúcar<br /> <?php $sql="SELECT * FROM test ORDER BY id LIMIT 3"; $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row=mysql_fetch_row($result)) { echo $row[1]."<br />"; } } ?> </body> </html> my result: words in HTML appear exactly as I typed them, but the ones coming from DB appear with those unknown characters. what to do? i tried everything
  7. hi, I'm making a website, in portuguese, and i'm trying to retrieve characters with accent signals such as é ê á etc. while when I directly type words with such characters directly in my HTML, it displays correctly (i'm using utf-, if i save the same words into a mysql DB, and echo them out with php, they will appear with missing characters, you know, the "?" inside a square. im clueless. any help is appreciated. thanks in advance
×
×
  • 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.