wesleypipes Posted October 30, 2006 Share Posted October 30, 2006 [code]<?phpsession_start();if (!isset($_SESSION["authenticatedUser"])){ $_SESSION["message"] = "Please Login"; header("Location: login.php");}else{?><body><h2>Youre ok you are authenticated as <?php echo$_SESSION["authenticatedUser"] ?> </h2><a href = "logout.php">logout</a></body></html><?php}?>[/code] Quote Link to comment Share on other sites More sharing options...
shadow-x Posted October 30, 2006 Share Posted October 30, 2006 It seems fine to me, why do you ask? are you getting an error message or just wanted to check the coding?one way of checking the format and coding of the script is to simply run it on a webserver (either locally on a devlopment environment or on a webhost), If there are any real problems with the code php will give out an error message. Unless its something minor that wont affect the code, in which case it normally isn't worth worrying about anyway. Quote Link to comment Share on other sites More sharing options...
wesleypipes Posted October 30, 2006 Author Share Posted October 30, 2006 Basically, I log in through a form, below is the code that proceeds<?phpmysql_connect("localhost", "root", "") or die(mysql_error());mysql_select_db("memberdir") or die(mysql_error());$appusername = $_POST['login_name'];$apppassword = $_POST['password'];$result = mysql_query("SELECT * FROM `user` WHERE username = '$appusername' AND password = '$apppassword'");if (mysql_num_rows($result) > 0) { $_SESSION['authenticatedUser'] = $appusername; header("Location: loggedon.php");}else { $_SESSION['message'] = "Could not connect as $appusername"; header("Location: login.php");}?>ok now if i log in with a valid user, i should get notifed and the first bit of code i post should do this if you get what i mean Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.