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] Link to comment https://forums.phpfreaks.com/topic/25600-is-the-format-of-this-loggedonphp-program-ok/ 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. Link to comment https://forums.phpfreaks.com/topic/25600-is-the-format-of-this-loggedonphp-program-ok/#findComment-116851 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 Link to comment https://forums.phpfreaks.com/topic/25600-is-the-format-of-this-loggedonphp-program-ok/#findComment-116855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.