Ok now i want to create a user login box with a remember me checkbox, if a user checks the checkbox then it will store the value in a cookie else it will store in a session var not i am a newbie so how do i do that can anyone please explain?? my form is <form action="index.php" method="POST"> <input name="user" type="text" size="32" /> <input name="pass" type="text" size="32" /> <input name="remember" type="checkbox" /> <input type="submit" value="submit" /> </form>
sorry if for got to post the php code <?php session_start(); include realpath('init.php'); include(BB_INC.'config.php'); $bbuser = $_POST['user']; $bbpass = $_POST['pass']; $bbremember = $_POST['remember']; $user = stripslashes($user); $pass = stripslashes($pass); $login = sprintf("SELECT * FROM user WHERE user='%s' AND pass='%s'", mysql_escape_string($user), mysql_escape_string(md5($pass))); mysql_select_db($database_config, $config); $logged = mysql_query($login, $config) or die(mysql_error()); $row_user = mysql_fetch_array($logged); if (mysql_num_rows($logged) == 0){ header (sprintf("Location: ../login.php")); } else { if ($remember){ setcookie("user", $user, time()+3600*24); header (sprintf("Location: ../index.php")); } else { $_SESSION['user'] = $user; header (sprintf("Location: ../index.php")); } } ?>