steepe Posted October 25, 2007 Share Posted October 25, 2007 Sorry guys, its me again! I'm just learning php and seem to have problems with creating a login application using sessions. Can anybody help? Quote Link to comment https://forums.phpfreaks.com/topic/74746-login-applicatins/ Share on other sites More sharing options...
pocobueno1388 Posted October 25, 2007 Share Posted October 25, 2007 Could you post the code you have? If you are having trouble getting started, there a plenty of tutorials out there. Quote Link to comment https://forums.phpfreaks.com/topic/74746-login-applicatins/#findComment-377856 Share on other sites More sharing options...
The Little Guy Posted October 25, 2007 Share Posted October 25, 2007 http://phpsnips.com/help.php?hlp=Login&id=3 Quote Link to comment https://forums.phpfreaks.com/topic/74746-login-applicatins/#findComment-377861 Share on other sites More sharing options...
steepe Posted October 25, 2007 Author Share Posted October 25, 2007 $username = $_POST['username']; $password = $_POST['password']; if(isset($username)){ $conn = mysql_pconnect("localhost","root",""); mysql_select_db("useraccount"); //$sql = ; //echo "sql = $sql"; $result = mysql_query("SELECT * FROM userauth WHERE username = '$username' AND pswd = md5('$password')"); $rows = mysql_fetch_assoc($result); if(is_array($rows)){ session_start(); $_SESSION['username'] = $rows['username']; echo "do_login: name =".$_SESSION['username']; //echo $rows['pswd']; if($_GET['p']){ $page = $_GET['p']; }else{ $page = "member.php"; } //echo "page ".$page; header("Location: ./$page"); } else { header("Location: ./fail.php"); } } ?> utils.php <? session_start(); $array = explode('/', $_SERVER['SCRIPT_FILENAME']); $page = array_pop($array); //echo "page ".$page; //echo "name =".$_SESSION['username']; $username = $_SESSION['username']; if(!$username){ header("Location: login.php?p=$page"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/74746-login-applicatins/#findComment-377887 Share on other sites More sharing options...
The Little Guy Posted October 25, 2007 Share Posted October 25, 2007 did you have a question about that? Quote Link to comment https://forums.phpfreaks.com/topic/74746-login-applicatins/#findComment-377890 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.