Forum Moderators: coopster

Message Too Old, No Replies

How to remember the user on a pc.

         

shruti

7:50 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



What do I have to do so that once the person logs in on that Pc, it asks him, DO you want to rememeber, Never, Not now?

And then when he get on the pc and opens this page he gets on the main page?

How is that done?

<?php

$connection = mysql_connect("localhost", "root", "") or die("Cannot connect to MySQL server: " . mysql_error());
$db_selected = mysql_select_db('tmetrix', $connection);

session_start();
$username = $_POST['username'];
$password = ($_POST['password']);

$query = "select * from users where username = '$username' and password = '$password'";

$result = mysql_query($query);

if (mysql_num_rows($result) != 1) {
$error = "Bad Login";
include "login.html";

} else {
$_SESSION['username'] = "$username";
header("location:main.php");
}

?>

eelixduppy

4:53 am on Aug 7, 2008 (gmt 0)



You have to set a cookie to remember a user. Look at setcookie [php.net] for additional information.